Arnob's blog

By Arnob, history, 5 months ago, In English

অদ্ভুত coders of Codeforces!!! (অদ্ভুত is a commonly used word in KUET meaning amazing)

We are thrilled to invite you to to participate in Replay of Ostad Presents Intra KUET Programming Contest 2023 which will be held on Tuesday, October 10,2023 at 19:00 (UTC+6).

You will have 5 hours to solve 13 problems. It is a beginner friendly contest. Teams preferred.

Thanks to the setters and testers of the contest: Mohaimin66, RUDRA_DAS, Likhon5, AngryBaymax, BrehamPie, Arnob, MinhazIbnMizan, weavile, Parvej, Noctambulant, Sabbir1807070, ShorifulSoumic, NM_Mehedy, Emon72, Creeping_Death_, brute__force__, _return_void_, Rafi, UmSuperNoob.

We hope you will enjoy the problemset.

UPD: Editorial

  • Vote: I like it
  • +41
  • Vote: I do not like it

»
5 months ago, # |
  Vote: I like it +8 Vote: I do not like it

There's a typing mistake. It will be "Tuesday, October 10,2023"

  • »
    »
    5 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Updated. Thanks for spotting. Sorry for the inconvenience.

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Arnob (previous revision, new revision, compare).

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I can't see any register button

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Registration will start at 1:00 pm.

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve problem I???

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Put 'a' on every leaf and 'b' on every non-leaf or vice versa. It was out solution but it is not correct. You can create more optimal solutions using other characters. And I have no idea how to solve it. One case where our solution fails:

    case
»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Will we get any editorial?

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Unfortunately no, You can ask for solution ideas of some particular problem here, We'll try respond.

  • »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Editorial of the contest has been posted. Check it out.

    • »
      »
      »
      4 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      #include<bits/stdc++.h> using namespace std; #define pi acos(-1.0) pair< double, double> rot(pair< double, double> i, double theta) { return {i.first*cos(theta)+i.second*sin(theta),-i.first*sin(theta)+i.second*cos(theta)}; } int main() { int t; cin>>t; while(t--) { long long a,b,m,n,theta; cin>>a>>b>>m>>n>>theta; vector<pair< double, double>>pp; long long g=gcd(m,n); m/=g; n/=g; pp.emplace_back(0,0); pp.emplace_back(b,0); pp.emplace_back(b,a); pp.emplace_back(0,a); for(auto &i:pp) { i=rot(i,pi*theta/180.0); } double d1=1e10, d2=1e10; for(auto i:pp) { d1=min(d1,i.first); d2=min(d2,i.second); } double wd=0,hd=0; for(auto &i:pp) { i.first-=d1; i.second-=d2; wd=max(i.first,wd); hd=max(i.second,hd); } long long lo=0,hi=1e10,ans=0; while(lo<=hi) { long long mi=(lo+hi)/2; long long w=n*mi,h=m*mi; if(wd-w<=1e-6 and hd-h<=1e-6) { hi=mi-1; ans=mi; } else lo=mi+1; } cout<<m*ans<<" "<<n*ans<<endl; } return 0; }

      In the code above if eps>1e-6 i got an WA . And how someone possibly know that he will got an WA for that ?

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Code of problem k is provided below can anyone tell me why it shows wrong answer on test 2 .i have observed if sum of digits is divisible by 3 then that number is divisibld by 3 .so i make an digits array then count number of subarrays having digitsum 3 .#include

include

include

using namespace std;

int solution(vector arr, int n, int k) { int ans = 0; map<int, int> map; map[0] = 1; int sum = 0; int rem = 0; for (int i = 0; i < n; i++) { sum += arr[i]; rem = sum % k; if (rem < 0) { rem += k; } if (map.find(rem) != map.end()) { ans += map[rem]; } map[rem]++; } return ans; }

int main() { int t; cin >> t; while(t--){ int m,n; cin >> m>>n; vectorarr(m); string str = to_string(n); // int arr[m]; for (int i = 0; i < m; i++) { arr[i]=str[i]-'0'; } int k; k=3; cout << solution(arr, m, k) << endl; } return 0; }

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The input $$$n$$$ cannot be stored in a 32 bit integer.

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve B ??

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Update

Editorial of the contest will be posted soon.

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

include

include

include

using namespace std;

int solution(vector arr, int n, int k) { int ans = 0; map<int, int> mp; mp[0] = 1; int sum = 0; int rem = 0; for (int i = 0; i < n; i++) { sum += arr[i]; rem = sum % k; if (rem < 0) { rem += k; } if (mp.find(rem) != mp.end()) { ans += mp[rem]; } mp[rem]++; } return ans; }

int main() { // int t; int t; cin >> t; while(t--){ int m;string str; cin >> m>>str; vectorarr(m); // string str = to_string(n); // int arr[m]; for (int i = 0; i < m; i++) { arr[i]=str[i]-'0'; } int k; k=3; cout << solution(arr, m, k) << endl; } return 0; }

NOW I HAVE DONE IT CORRECTLY IN O(M) STILL I GOT TLE

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    std::ios::sync_with_stdio(false); std::cin.tie(nullptr);

    type this in the main function before the input

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Arnob (previous revision, new revision, compare).

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Arnob Brother, in L. not-incomplete question, why x constraint in 12 to 14?

question link: https://mirror.codeforces.com/gym/104663/problem/L?fbclid=IwAR3ZRc0KoevcYUKfBj2CT8GCs1kCBvxSsvfzXzGn6xo8jUCP_tK1o8IWTJI

  • »
    »
    3 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    We tried to keep it realistic. Each semester normally consists of 12 to 14 weeks.