We will hold AtCoder Beginner Contest 136.
- Contest URL: https://atcoder.jp/contests/abc136
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20190804T2100&p1=248
- Duration: 100 minutes
- Number of Tasks: 6
- Writer: DEGwer, Drafear, evima, satashun
- Rated range: ~ 1999
The point values will be 100-200-300-400-500-600.
We are looking forward to your participation!
How to solve E? ._.
Notice that any number X which divides all the elements of the array also divides the sum of the array. Moreover, the sum is constant after any number of operations.
Therefore, we iterate over all the divisors of the original array, and find the highest divisor which can be the answer.
For checking if X is valid, I found A[i] % X for all A[i], pushed them into an array, sorted them, and then tried to reduce the left ones and increase the ones on the right to minimise the number of operations required.
Code: https://atcoder.jp/contests/abc136/submissions/6699490
Can someone explain E and F??
They are explained in detail on my blog, but the gist is that for E, we should check whether each factor of the sum of the values in the array is achievable. We can use a greedy strategy to compute the minimum number of moves necessary to make all of our numbers divisible by one of these factors. For F, we use the Principle of Inclusion/Exclusion, along with a segment tree to track some important values. (Full details are on the blog.)
My solutions are up at https://codeforces.me/blog/entry/68900, for anyone interested.
Thanks for the editorial @geothermal
Thanks for quick and well-explained editorial after each Atcoder contest!
Can you help me understand how idea of parity worked in problem D's solution?
Whenever a child moves, the parity of its position changes, as any odd position is adjacent to two even positions, while any even position is adjacent to two odd positions. Hence, after $$$10^{100}$$$ moves, the parity of its resulting position will be the same as the parity of its original position, since the parity will have switched an even number of times. Once we've found two adjacent positions each child could end up in, therefore, we can pick the one with the same parity as the child's original position.
How to Solve D ???
You can maintain the prefix and suffix sums of
L
andR
in each grid, while resetting them to $$$0$$$ when the letter in the grid is not the same as the one you want to maintain.This seems a little bit hard to understand, so code is here:
where the $$$prel,prer,sufl,sufr$$$ arrays denote the prefix and suffix sums.
Then, you can see that if a child wanders to
RL
, he would always be wandering between these two grids. So a child would go one direction (as the one written in his grid) until he arrives toRL
, since $$$10^{100}$$$ is a huge even number, you can assume that the movements fall into a 2-loop, count the prefix and suffix sums and you will know the answer.To understand the parity, you can write down the direction a child takes, and you'll find it's either
RRRRRRR...RRRLRLRLRLRLRLRLRLRLRLRLRLRL...
orLLLLLL....LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL...
, and you can find that it repeats after some time.Well find the closest opposing character in proper direction (for R, the closest L to right // for L, the closest R to left).
It is easy to see that the child will step there "once".
It is also easy to see that the child will "rotate" there + on its neighbor (before it) ..co in some "RL" substring :)
To see where it will end, simply check the parity of distance.
Good Luck & Wish you a nice day!
Isn't it RL substring?
You are right — thanx :)
Repaired :))
E and F were written by me. Thank you for participating!
Can anyone help me find out what is the problem of my code of F?Thx https://atcoder.jp/contests/abc136/submissions/6720126,it wrong 2 of the testdatas.
Can anyone give a solution for question D??
https://atcoder.jp/contests/abc136/submissions/6698199
Hey, I tried to solve C, but get a wrong answer. Can someone help me to find why my way is wrong?
I just check whether there is difference more than 1 or there is continuous difference of 1 just like 9 8 7 ,so ,what's wrong?I can not solve it. Please.\ That's my code.
int a[100000+50]; int main() { int T=1; while(T--){ int n=read(); rep(i,1,n) a[i]=read(); int flag=1; //int num=0; rep(i,1,n-1) { if(a[i]-a[i+1]>1) {flag=0;break;} if(a[i]-a[i+1]==1) { if(i<n-1) { if(a[i+1]-a[i+2]==1) {flag=0;break;} } } } if(flag) puts("Yes"); else puts("No"); } }
Check if you pass:
As far as I can tell your code misses the differences offset by equal values.
My solution for F using inclusion/exclusion and AVL tree for order statistic Code : https://atcoder.jp/contests/abc136/submissions/6742192
Can someone please check my code for $$$E$$$ and point out the mistake. It's failing 10 out of 84 test cases : Solution
For E I accidentally solved it in a different way than others told. The part till possible answers are divisors of total sum is same, for checking validity of a divisor(g), let m be number of elements that are to be increased,then we can conclude that m=(sum of remainders obtained when divided by g)/g and required moves are total sum of remainders-sum of these m remainders, now we are left with to find largest sum of size m, this can be done by taking m largest remainders.
Link to submission: