### maroonrk's blog

By maroonrk, history, 12 days ago,

We will hold AtCoder Regular Contest 113.

The point values will be 300-400-500-600-800-1000.

We are looking forward to your participation!

• +97

 » 12 days ago, # |   +23 Clashes with open cup. Can it be pushed an hour?
•  » » 12 days ago, # ^ |   +47 I'm sorry, but we can't move the contest time. Maybe you can virtual-participate in the Opencup.
•  » » 12 days ago, # ^ | ← Rev. 2 →   -14 Clashes with innopolis-open finals as wellEdit:doesn't clash(I thought innopolis is 5 hours instead of 4)
 » 11 days ago, # |   +22 This contest will be hold on the old rating system, right?
•  » » 11 days ago, # ^ |   +13 Yes.
 » 11 days ago, # | ← Rev. 2 →   +24 was C easy than B ?? or its only for me ?
•  » » 11 days ago, # ^ |   0 Agreed.
•  » » 11 days ago, # ^ |   +12 C was easy than B but solution of B was on internet so lot of people solved it very quickly .
•  » » 11 days ago, # ^ |   0 I found A the hardest in A,B,C
 » 11 days ago, # | ← Rev. 2 →   +135 New difficulty staircases with a wall
•  » » 11 days ago, # ^ |   +49 Who solved F are in almost 2000-st place because F costs 110min...
•  » » » 11 days ago, # ^ |   +7 Thats why there a wall. You either choose ABCD(and E?) or F
 » 11 days ago, # | ← Rev. 3 →   +12 If you're having trouble working out the edge cases, B can be solved with Berlekamp-Massey: https://atcoder.jp/contests/arc113/submissions/20391652 codell a, b, c; re(a, b, c); a %= 10; vmn ans_seq{}; for (int i = 0; i < 100; i++) { ans_seq.push_back(a); { vmn a_seq{1}; for (int j = 0; j < 100; j++) a_seq.push_back((a_seq.back().v * a) % 10); LFSR A(a_seq); a = A[b].v; } } LFSR ANS(ans_seq); int ans = ANS[c].v; ps(ans); Edit: I solved it the traditional way first.
•  » » 11 days ago, # ^ |   +54 Killing a mosquito with a bazooka.Why edge cases though? Couldn't you hardcode the periods of powers of 0-9, and use that?
•  » » 11 days ago, # ^ |   +1 You can also notice that all the numbers 0-9 will repeat the same ones digit every 4 powers.
•  » » 11 days ago, # ^ |   +5 For B, here's a simpler solution.We know that $A, B, C > 1$ and the modulus is 10. The period is always a divisor of 4, so it suffices to find $B^C$ modulo $4$, say $x$, and find $a^{x + 4}$ modulo $10$.
 » 11 days ago, # |   +10 Problem B was already available on Stackoverflow (*_*).
 » 11 days ago, # |   +8 how to solve D
•  » » 11 days ago, # ^ | ← Rev. 3 →   +11 Let $n>2,m>2$. Then observe that the only constraints on $A$ and $B$ are that $\forall i, B_i > max(A)$. So, we can find for a given maximum $x \in [1,k]$ the number of different sequences $A$ such that $max(A) = x$, which is $x^{n} - (x-1)^{n}$. Then, the number of sequences $B$ such that $B_i \geq x$ will be $(k-x+1)^m$. Multiply these values and add them for all $x$, and you have your answer.Handle $n=1$ and $m=1$ separately.Complexity is $O(k(\log m + \log n))$.
•  » » » 11 days ago, # ^ |   +1 can you please tell why number of different sequences $A$ such that $A_i<=x$ is $x^n - (x-1)^n$ . Shouldn't it be just $x^n$.
•  » » » » 11 days ago, # ^ |   +4 I should have made it clear — the maximum of $A$ is $x$, so that means there must be at least one $i$ such that $A_i = x$. This is why I subtract $(x-1)^n$, to remove all the sequences where the maximum value is less than that. I'll edit the comment to reflect that.By the way, \leq for less than or equal to sign
•  » » » » » 10 days ago, # ^ |   -10 Excellent Explanation.
•  » » » » 11 days ago, # ^ |   0 At least one of them should be x.
•  » » » 3 days ago, # ^ |   0 In the first line of the comment, I think it should be Bi >= max(A) instead of Bi > max(A) ??
•  » » 11 days ago, # ^ |   0 The answer turns out to be the number of monotone $k-$weightings of a complete bipartite digraph with $n$ vertices on the left and $m$ on the right for $n, m > 1$. For $\min(n, m) = 1$ the answer is $k^{\max(n, m)}$.
 » 11 days ago, # |   +19 Why problem E is sooooooooo much harder than D (
•  » » 11 days ago, # ^ |   +10 Toooooooooooooo complicated!
 » 11 days ago, # | ← Rev. 3 →   +3 My somewhat readable solutions for anyone interested: A#include "bits/stdc++.h" using namespace std ; int fc(int n) { int s=0 ; for (int i=1;i*i<=n; i++) { if(n%i==0&&n/i==i) ++s ; else if(n%i==0) s+=2 ; } return s ; } int main(){ int k ,ans=0; cin>>k ; vectordp(k+1) ; for(int i=1;i>x>>y>>z ; x=x%10 ; if(x==0||x==1||x==5||x==6){ cout<cyc; cyc={x*x*x*x%10,x,x*x%10,x*x*x%10} ; y=pM(y,z,(int)cyc.size()) ; cout<>s ; int n = s.size() ,ans=0 ; vectorc(26) ; for(int i=n-1,j=0;~i;--i,j++){ if(i>n>>m>>k ; if(n==1||m==1){ cout<
•  » » 11 days ago, # ^ | ← Rev. 6 →   +5 Edit:Brute force is actually $O(n \ log \ n)$ (?) but i'm not sure... It is $\sum_{i=1}^n \frac{n}{i}$
•  » » » 11 days ago, # ^ |   +1 True, now I get how even low rated people solved this in 2 minutes :P
•  » » » 11 days ago, # ^ |   0 Can you please explain the time complexity of this . I am having difficulty in understanding this. Isn't it be O(n^3/2)
•  » » » » 11 days ago, # ^ |   0 It'll be O(n^3/2). The comment is mentioning the complexity of the brute solution as O(n log n).
•  » » 11 days ago, # ^ | ← Rev. 2 →   +6 A can also be done with 3 forloops from 1 to n if you just break the loop when i*j>n or i*j*k>n. code ll ans=0; for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ if(i*j>n) break; for(ll k=1;k<=n;k++){ if(i*j*k<=n) ans++; else break; } } } cout<
•  » » » 11 days ago, # ^ |   +9 Ah... now I feel stupid, after missing such a neat solution XD.
•  » » 11 days ago, # ^ |   0 why are u choosing <= i as maximum for m but exact i for choosing minimum in D??
•  » » » 11 days ago, # ^ |   +5 Would you mind elaborating? I didn't get your point?
•  » » » » 11 days ago, # ^ | ← Rev. 2 →   0 like lets say question was maximum in row and maximum in column, then we take exact i instead of <= i for both row and column, we do that by $i^n - (i-1)^n$ , but here we are not doing like that why?? link i read from here for our version we need minimum for first n elements, so i thought we must need exact i, so it must be $({i,i+1,....k})^N/({i+1,....k})^N$
•  » » » » » 11 days ago, # ^ |   +1 I think we can do this here too. The only critical observation was this: $B_j \ge \max_{1 \le i \le n}(A_i)$ $\forall$ $1 \le j \le m$ Now What I do is iterate from $i=1...k$ and for each $i$ we can find the number of $A's$ which will have their maximum value to be exactly equal to $i$ by $a_i=i^n-(i-1)^n$ now once we've got this. The final task at hand is to find all possible $B's$. And that'd be equal to $b_i=(k-i+1)^m$ (as we don't really care what the elements of $B$ are as long as they're all greater than $i$ so we can choose any of the values from $i \dots k$ for each of the $m$ values of array $B$). Hence our answer $s$ would just be given by $s=\sum_{i=1}^n(i^n-(i-1)^n)(k-i+1)^m$
•  » » 11 days ago, # ^ |   0 not so difficult to understand （ actually too lazy to explain ）
•  » » » 10 days ago, # ^ |   +5 This is $O(n^{3/4})$.
•  » » » » 10 days ago, # ^ |   0 oh sorry for that （ by the way % ATS ）
 » 11 days ago, # |   +43 I believe I have missed one out of 12321 cases in E.
 » 11 days ago, # |   +18 Problem D was similar to this but with weaker constraints.
 » 11 days ago, # | ← Rev. 4 →   0 why is this wrong for D Spoilerint ans = 0; fr(i,k){ int f1 = 0; int t1 = k - 1 - i + 1; int t2 = k - 1 - (i + 1) + 1; // if(i <= k - 1) f1 = (f1 + fpow(t1, n)) % mod; // if(i + 1 <= k - 1) f1 = (f1 - fpow(t2, n) + mod) % mod; int f2 = 0; f2 = (f2 + fpow(i + 1 , m)) % mod; f2 = (f2 - fpow(i, m) + mod) % mod; ans = (ans + f1 * f2 % mod) % mod; } cout << ans; https://math.stackexchange.com/questions/3260717/how-to-count-the-number-of-different-sequences-possible?noredirect=1
 » 11 days ago, # |   +20 So I printed (max(n,m)+k-1 choose k-1) instead of k^max(n, m) in D and failed to see this bug for 10 mins. Cost me over 1100 places :thonkms:
 » 11 days ago, # |   -10 Can someone explain why doing brute force in A doesn't give TLE?
 » 11 days ago, # | ← Rev. 3 →   0 B can be solved without period observation.let's define f(a,b,c) = a^b^c = {a^b^(c/2)}^b^(c/2)then f(a,b,c)=f(f(a,b,c/2),b,c/2) so we can do DP.https://atcoder.jp/contests/arc113/submissions/20381459
 » 11 days ago, # |   0 So lucky to have E accepted at the last 3 minutes. I was wondering if F is easier than E when I was reading the problems and tried to work F out for tens of minutes, fortunately I did not continue doing that...
 » 11 days ago, # |   0 Sad.Problem E always wrong on test 1,2. AC another 44 tests.
 » 11 days ago, # |   +34 So, how to solve E?
•  » » 11 days ago, # ^ |   +8 There are so many situations to consider: note that we can almost keep all b's except some special cases, and cancel all the a's to 0 or 1 if we want, the problem becomes "how to arrange the rest of a's" and "how many a's we can keep at the end of the final string". All the a's are at the beginning: we cannot do anything to make b at the beginning, so we should keep 0 or 1 a at the beginning(depending on the parity of number of a's) and keep all the b's. There are some a's at the end: we should move the continuous a's to the end by an operation, and by one operation with $k$ continuous a's we can increase the length of suffix with all a's by $k - 2$, so we only move those larger than 2 to the end. No a's at the end: if the parity of total number of a's is even, we just cancel all the a's, otherwise, we must keep some a's between b's, or we need to remove (at most 2) b's to make a's at the end. When the suffix of b's is no longer than 2, we can keep the last a and remove any other a's, otherwise, try to keep the longest suffix of a's by removing 2 b's. I haven't found a "clean" solution yet...
 » 11 days ago, # |   +15 This is the second time I participants in ARC, and it's difficult for me as usual.I tried my best and solve the first four problems, after this, I'm almost exhaust and didn't have too much time thinking about the rest.I can't understand why all the people around me are saying:"The first four problems are very simple!", maybe it just because I'm too weak to join ARC:(All in all, I hope all of you can enjoy the contest, just like I did!
 » 11 days ago, # |   0 What is wrong in B in this approach ? https://atcoder.jp/contests/arc113/submissions/20391199
 » 11 days ago, # | ← Rev. 2 →   0 Can anyone tell me what is the difference between these 2 codes for B, and why doing +4 is important? I also checked 'b' is never -ve when I submit it.AC code: void solve(){ ll a, b, c; cin >> a >> b >> c; b = power(b, c, 4)+4; a = power(a, b, 10); cout <> a >> b >> c; b = power(b, c, 4); a = power(a, b, 10); cout <
•  » » 11 days ago, # ^ |   0 what if power(b,c,4) = 0 check for TC 2,2,2
•  » » » 11 days ago, # ^ |   0 oh ok. Thank you.
•  » » 11 days ago, # ^ |   0 If pow(b, c) % 4 == 0 Output will be always 1. So adding 4 I guess
 » 10 days ago, # | ← Rev. 2 →   0 So, how to solve F？Could anybody tell me the expanation of dp[i][j][k] -> dp[i + 1][j][k + 1]'s "weight" is 1/(k+1)