|
0
change to |
|
0
This was the edge case, thanks! Forgot to handle self cycle. |
|
0
Can't seem to get D to AC, failed 6 test cases. My idea is to label $$$2*i$$$ as blue and $$$2*i + 1$$$ as red for $$$i \in [1, n]$$$ and treat it as a graph dfs problem Spoiler |
|
0
don't post your code, instead use spoiler tags Спойлер or just give a link to your submission |
|
0
First find the maximum amount of digits, $$$nDigits = N / mn$$$ where $$$mn$$$ is the minimum over all $$$C_i$$$. After that, loop from the most significant to the least significant digit while greedily assigning the digit's number by taking the maximum $$$j, j \in [1, 9]$$$, where $$$n - C_j \geq rest * mn$$$. $$$rest$$$ is the number of remaining unassigned digits. After a valid $$$j$$$ is found, reduce $$$n$$$ by $$$C_j$$$. |
|
0
Got it, so basically we need to minimize the difference between the two subsets and add to the smaller subset powers of two that add up to that difference. Thanks a bunch. |
|
0
Can you share your thought process on how you came up with the first 30 numbers being powers of two? |
|
+1
Super helpful blog! Google Kickstart 2020 Round D — Beauty of Tree is also a cool problem that can be solved with the "contribution" technique. |
|
+3
I completely agree. Combined with the short statements, i always learn something new from ABC, especially D/E/F |
|
0
I didn't think it was impl-heavy. Notice you can determine the coefficient of $$$B_i, 0 \leq i \leq m$$$ from Spoiler |
|
+3
Notice you only need to do [0, 1] operation either vertically or horizontally (chessboard of size 1x2 or 2x1). Do this backwards for every row and column where there is a black cell. Edge case is when top left column is black. |
|
0
You can also do $$$dp[index]$$$, where $$$dp[i]$$$ denotes the number of lexicographically smaller strings for index $$$i, 1 \leq i \leq \frac{(n+1)}{2}$$$. Finally, define $$$t$$$ as follow: If the string $$$t$$$ is lexicographically smaller than $$$s$$$, or with c++ you can just check if $$$t \lt = s$$$, add 1 to the answer. submission |
|
0
Here is a similar, but simpler problem to better help understand converting to other bases. C — One Quadrillion and One Dalmatians |
|
0
It's the prefix sum of the cost, which is:
|
|
На
chokudai →
TOYOTA SYSTEMS Programming Contest 2021(AtCoder Beginner Contest 228) Announcement, 4 года назад
0
Use |
|
На
ilovehitagi →
Help with AtCoder Beginner 222 D - Between Two arrays, segtree/bit approach, 5 лет назад
0
I haven't implemented a BIT solution, but found one that got accepted. Hopefully, it helps. submission |
|
0
Thank you, will keep that in mind |
|
0
Edge case when $$$n \lt = 2$$$, output should be 0 |
|
0
Really liked the problems! Can anyone point out my mistake on B? Submission I used bitmasks to simulate the removed numbers, implementation was buggy as it keeps getting WA on test 2 |
|
На
chokudai →
Exawizards Programming Contest 2021(AtCoder Beginner Contest 222) Announcement, 5 лет назад
+3
Neat trick! Will keep this in mind for similar problems. Thanks! |
|
На
chokudai →
Exawizards Programming Contest 2021(AtCoder Beginner Contest 222) Announcement, 5 лет назад
0
Output is the $$$id's$$$ sorted by their rankings decreasingly (bigger ranking -> more wins, or if same number of wins the smaller id gets the better rank). What you need to do is make a custom comparator for your rankings array and sort them for every match. I agree statement was bloated and implementation was not fun :( |
|
На
chokudai →
Sciseed Programming Contest 2021(AtCoder Beginner Contest 219) Announcement, 5 лет назад
0
Thank you, how do you know when to do heavy-light splitting? I'm having trouble identifying this type of problem |
|
+3
oh what a silly mistake. Thanks! |
|
0
Any idea how to solve E? I used set for the sorted items and queue for the unsorted. Implementation was full of bugs I suppose as I got 8 WA. |
|
+3
Oh yeah that was an edge case. Glad I could help |
|
+3
I don't know about your implementation, but I used and reduce with n-curK using the same formula. Submission |
|
0
You should use adjacency list instead of adjacency matrix for checking the banned ways, improving from $$$n^2$$$ to $$$n + 2*m$$$ for the inner loop when reducing the banned ways |
|
0
D was nice, even though I couldn't pass all test cases |
|
0
I'm also curious why my submission outputs empty while locally it works fine. (Josephus Problem I btw) (disclaimer: code is ugly) submission Would be a huge help if anyone can figure out why :) |
|
0
Great explanation, helped me understand DP a bit better. Thanks. |
|
0
Can anyone help explain how we get the number of banned ways here? I'm still confused while reading the editorial. Will update if I can think of a beginner friendly explanation. |
|
0
Okay so I finally understood the method. Basically after computing the co-rime pairs, we loop Why we have a convincing pattern, the top and left borders are the let's see another example it looks like the pattern persists, and this is the reason of doing detailed explanation of example test case [3, 8] Hope this helps, highly suggesting reading this as well if you want to understand what mobius functions does! |
|
0
I walked through the example test case, which might be helpful to whoever is still confused |
|
0
i saw submissions from the leaderboard do this after computing the number of coprimes [L, R] I know it has something to do with removing |
|
0
I think the key observation is that for every possible subset sum |
|
+3
Thank you, very clean and understandable solution |
|
0
Thanks, really nice problem |
|
+10
Sorry for the vague question, I was referring to your submission. Thank you nonetheless. Love your streams btw, hope you do more in the future. |
|
+10
Can you explain why we do |
|
На
chokudai →
KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) Announcement, 5 лет назад
0
|
|
На
chokudai →
KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) Announcement, 5 лет назад
0
For those who are weak in combinatorics and don't know how to solve E with it (like me), here is my submission with detailed comments. Main idea was from thescrasse's submission See also this comment to understand more about inclusion-exclusion principle. Hope this helps |
|
На
chokudai →
AISing Programming Contest 2021(AtCoder Beginner Contest 202) Announcement, 5 лет назад
0
Thank you, very detailed and understandable explanation. |
|
0
Thanks, this helped a lot |
|
+6
Thanks you, this is very helpful |
|
0
Nice explanation, a bit of typo, should be $$$a[i] = (1,3),(1,4),(3,4)$$$ |
|
0
Yeah, I learned to understand when to return lo and hi, rather than just memoziring it. Thanks! |
|
На
__SHERLOCK__ →
After attending 30 contests, I can't become even 'Pupil'. Can you please help me to find out my faults?, 5 лет назад
0
Thank you for sharing, I hope this will help me get to pupil :) |
|
0
Another way to think about it is the property of odd numbers which is n & 1. If there is an odd element, then the minimum number of trailing zeros is 0, the odd number. If there is no odd number, that means every element has a bit sequence of where there are trailing zeros. From your example, Dividing all the elements by two is the same as removing the trailing zero (which all elements have) until there is an odd number (the least significant bit is 1) After this operation is done, you're guaranteed to not be able to split the elements, |
|
0
Awesome explanation, thanks! |
|
+4
partitionForces |
|
На
chokudai →
Panasonic Programming Contest (AtCoder Beginner Contest 195) Announcement, 5 лет назад
0
Thank you for the detailed explanation, I finally understood E. |
|
+23
Really nice problems, no idea how to solve them though lol |
|
+3
Really interesting problems, have no idea how to solve them though lol |
|
На
ch_egor →
Codeforces Round #707 (Div.1, Div.2, по Открытой олимпиаде школьников по информатике, рейтинговый), 5 лет назад
0
Thanks for the info! I've only used Atcoder Library on atcoder contests but I think I'll start using it on codeforces as well. |
|
На
ch_egor →
Codeforces Round #707 (Div.1, Div.2, по Открытой олимпиаде школьников по информатике, рейтинговый), 5 лет назад
0
What does NTT stand for? |
|
+5
thanks, changed from long long to __int128 and got AC |
|
0
Leaving this here hope it helps https://labuladong.gitbook.io/algo-en/iii.-algorithmic-thinking/detailedbinarysearch |
|
0
Ok got it, thank you for the very fast response |
|
0
In C2 solution and find_left binary search why do we return hi instead of lo? |
|
0
I see, thanks for pointing it out |
|
-14
C was a great question, I'm still confused though on my find_left function. at first, my mid calculations were the standard (lo + hi) / 2, but this causes infinity loop: then I changed it to (lo + hi + 1) / 2, then got AC: full code: Can anyone with a better understanding of binary search explain why this works? |
|
0
I like how menacing your comment is because of that duck |
|
0
I did nth_element(N/2) and got 1 wa. Any ideas? submission |
|
-9
i cry |
|
0
i cry |
|
+2
same here bud, keep going |
|
0
Oh wow that's such a cool way, thanks so much! |
|
0
Oh wow I'm dumb. Really appreciate the explanation! |
|
0
Can you explain why 2^k -1? I only know a(r^n -1)/r-1 to be the summation of geometric progression. |
|
0
input = n and k. max value (we dont need to consider the 10^100 as it will be canceled out) = 1+2+...+n = n(n+1)/2 for i = k; i<=n+1; i++, you have to count the number of different values. curmax = n(n+1)/2 — (n-i)(n-i+1)/2 // explanation: 1+2+...+n — (1+2+..+n-i) = n-i+1 + n-i+2 +...+ n-i+i curmin = i(i+1)/2 then we increment answer with curmax-curmin + 1 (zero based) |
|
0
i see. Thanks, your comment is very helpful. I'll keep this in mind for future competitions. |
|
0
yeah didn't realize that. Thanks! |
|
0
https://mirror.codeforces.com/contest/1337/submission/76887917 Can anyone help me find out why the last testcase wasn't printed? (locally it does) |
|
0
Thanks!. i would like to confirm some this line on your problem C solution. if(a[i] > b[p]){ ans += a[i] — b[p]; a[i] = b[p]; } What I'm getting is that this is to find the blasts that doesn't instantly kill the i+1 monster so add a[i] — b[p] to ans as in the number of bullets it will take to kill after explosion. And after that we find the minimum of all a[i]..a[n] and add it to the ans as the starting point and we don't have to do anything anymore because the blasts will insta kill everything. Correct me if I'm wrong, and thanks for the video! |
|
0
bruh |