### chokudai's blog

By chokudai, history, 15 months ago,

We will hold AtCoder Beginner Contest 136.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

• +36

 » 15 months ago, # |   +12 How to solve E? ._.
•  » » 15 months ago, # ^ |   +47 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.
•  » » 15 months ago, # ^ |   0 new to this site but have anyone tried binary search? i mean given a dividend we can use greedy method to judge whether it's possible and Nlog(K+max(array)) isn't too bad. although noticing the invariant is elegant, it's like kasiski's method.
 » 15 months ago, # |   +11 Can someone explain E and F??
•  » » 15 months ago, # ^ |   +9 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.)
 » 15 months ago, # |   +23 My solutions are up at https://codeforces.com/blog/entry/68900, for anyone interested.
•  » » 15 months ago, # ^ |   +10 Thanks for the editorial @geothermal
•  » » 15 months ago, # ^ |   +10 Thanks for quick and well-explained editorial after each Atcoder contest!
•  » » 15 months ago, # ^ |   0 Can you help me understand how idea of parity worked in problem D's solution?
•  » » » 15 months ago, # ^ |   +1 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.
•  » » » » 15 months ago, # ^ |   0 It will have same parity because 10^100 is even ?
•  » » 15 months ago, # ^ | ← Rev. 2 →   0 hey! Geothermal please give approach for B-uneven numbers that you mentioned in your editorial for complexity O(log(n)).
 » 15 months ago, # |   0 How to Solve D ???
•  » » 15 months ago, # ^ |   +1 You can maintain the prefix and suffix sums of L and R 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: int prel[MAXN], prer[MAXN], sufl[MAXN], sufr[MAXN], ans[MAXN]; for (int i = 0; i < s.length(); i++) { if (s[i] == 'L'){ prel[i] = prel[i - 1] + 1; prer[i] = 0; } else { prer[i] = prer[i - 1] + 1; prel[i] = 0; } } for (int i = s.length() - 1; i >= 0; i--) { if (s[i] == 'L') { sufl[i] = sufl[i + 1] + 1; sufr[i] = 0; } else { sufr[i] = sufr[i + 1] + 1; sufl[i] = 0; } } 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 to RL, 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.
•  » » » 15 months ago, # ^ |   0 To understand the parity, you can write down the direction a child takes, and you'll find it's either RRRRRRR...RRRLRLRLRLRLRLRLRLRLRLRLRLRL... or LLLLLL....LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL..., and you can find that it repeats after some time.
•  » » 15 months ago, # ^ | ← Rev. 2 →   0 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!
•  » » » 15 months ago, # ^ |   0 Isn't it RL substring?
•  » » » » 15 months ago, # ^ |   0 You are right — thanx :)Repaired :))
 » 15 months ago, # |   +24 E and F were written by me. Thank you for participating!
 » 15 months ago, # |   0 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.
 » 15 months ago, # |   0 How to Solve F ??? help me thanks
 » 15 months ago, # |   0 What is the difficulty level/rating of ABC's problems E & F as compared to codeforces's problems ?
 » 15 months ago, # |   0 Can anyone give a solution for question D??
•  » » 15 months ago, # ^ |   0
 » 15 months ago, # | ← Rev. 2 →   0 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
•  » » 15 months ago, # ^ | ← Rev. 2 →   0 Check if you pass: 4 9 8 8 7 As far as I can tell your code misses the differences offset by equal values.
•  » » » 15 months ago, # ^ |   0 wow!awesome!Thank you!
 » 15 months ago, # |   0 My solution for F using inclusion/exclusion and AVL tree for order statistic Code : https://atcoder.jp/contests/abc136/submissions/6742192
 » 15 months ago, # |   0 Can someone please check my code for $E$ and point out the mistake. It's failing 10 out of 84 test cases : Solution
•  » » 14 months ago, # ^ |   0 3 034 34 34
»
8 days ago, # |
-6

Why does not my code work for problem C? Any ideas?

// // main.cpp // atCoder Beginner Contest 136 // // Created by Osmel Lavalier Martin on 2020-10-13. //

# include <bits/stdc++.h>

using namespace::std;

# define deb(x) cout << #x << " " << x << endl

template<typename... T> void write(T&&... args) { ((cout << args << " "), ...); }

template<typename... T> void read(T&... args) { ((cin << args), ...); }

int main() {

int n; cin >> n; vector arr(n);

for(int i = 0; i < n; i++) cin >> arr[i];

bool correct = false;
for(int i = 0; i < n; i++) {
arr[i] -= 1;
if(is_sorted(arr.begin(), arr.end())) {
correct = true;
break;
}
}

if(correct) cout << "Yes" << endl;
else cout << "No" << endl;
`

return 0; }