Comments

Can anyone finds the runtime error in this code? Thank you!

1797D

+3

Thank you! I missed an edge case.

Explanation

Anyone knows why my submission for E is wrong?

https://codeforces.me/contest/1798/submission/199302004

My algorithm:

Spoiler

Personal take: ImplementationForces sometimes is actually good! Many real-life problem only require brute-force, yet hard solutions. ICPC-style contests also features many implementation-heavy problems. You do not need crazy algorithms or math knowledge to solve C,D, yet the amount of solves are perfect for problems of that level. Stress testing for D to find the exact solution is also a skill we need to have in real-life programming... The problems are also not misleading, so the only person that you can blame if you WA is you, right?

Math knowledge: Sum from 1 to N is N (N + 1) / 2.

Modulo knowledge: T (T + 1) mod N = (T + N) (T + N + 1) mod N

Therefore, just check I from 1 to N for I * (I + 1) / 2 + X mod N == 0.

That's what I thought, but WA on case something... change for from 1 to N to 1 to 2 * N works, but I don't understand how :D

ImplementationForces all the way

0

It's some DP with infinite series I think, got the transitions down but never solved it

Hint
Hint 2
Solution

Or maybe, still keep rooms, still have infinite hacks, but only give points to the first 3-5 successful hacks? After that, you can still hack, but it will not count toward point total.

Weirdly enough, yes! That's why C and D are all 1500 points. This contest's C and D are equal to normal C, and E is equal to (hard) D.

Ignoring the B question (I'm still self-debating whether hacks of this scale is good or not), the contest was really good! Maybe D was a bit too easy (implementation-forces), but E is certainly one of the best tree problem I've done! Thanks a lot to the authors for organizing the contest!

Root the tree at 1. What will you need to do if you want one of the pieces to go to a node with depth that is greater than d?

+1

facepalm I read the question wrong and thought that a good substring only need the final median to be good... Then I started to look at Pascal triangle and all those stuff...

Am I really not seeing something, or is C really addition of nC0 + nC1 + ... + nCk, where k is the amount of '0' or '1' depending on the last digit? If that's the case, how can I calculate it in O(n) or O(n log n)?

https://codeforces.me/contest/1771/submission/184787882

Anyone knows why is this wrong at pretest 3? Idea: Check all routes from one leaf to another. I could understand this getting TLE'd, but not WA

Just check and factorize every number until sqrt(n). The number remaining would be the remainding prime!

I used sieve for C — worked well within the time limit.

On ImakfCodeforces Global Round 24, 4 years ago
+8
Hint 1
Hint 2

If you need more help just reply!

Very clean code and solution, thank you! I knew that the solution is very clean, but did not have the skill to find it tho.

How to solve problem E? The most I can do is a brute force O(n^3) solution.

Factorize N, and then calculate how many numbers between 1 and M are divisible to any of the number factorized using the Inclusion-Exclusion formula:

https://www.geeksforgeeks.org/inclusion-exclusion-principle-and-programming-applications/

+1

Else,we need to find x,which makes a[l]⊕a[l+1]⊕...a[x]==0 and x−l+1 is odd.If such x exists,ans=2.Otherwise,ans=−1

How can you do this in log or smaller time? This is the only part where I got stuck in.

Oh my god that's literally an one-sentence answer that I've been trying to come up for almost two hours! Thank you! I've got to the part where I thought of the "depth or width" stuff, but I didn't find the general formula for it.

Anyone know what is pretest 6 in E? This contest is so much WA-in-pretests...

Do-you-know-calculus-forces

thanks so much for all the help! I cannot believe how did I miss that either, was the difference between -20 and +80 this contest lol

Oh my god why did I miss that... Thank you so much, forgot the initial part of modding the first

Thanks for your help! Unfortunately, I still could not find out what went wrong, maybe finishing it tonight tho...

I already defined int to be long long so the int stuff should work out normally

Sorry for posting the same solution :_: this is the with (m/2)%MOD but still wrong https://codeforces.me/contest/1749/submission/177215823 Do you have any links to learn modular arithmetic in CP so that these problems aren't happening again? Thank you!

Thanks for replying! I already tried (m/2)%MOD, but it is still wrong... https://codeforces.me/contest/1749/submission/177211216 There are probably a lot of things wrong in there TwT

To win a game with k turns, the array must have at least k '1', and at least 1 number that is smaller or equal to 2, 3, ..., k. This is because Bob can use a strategy to lock the final move out by adding to each '1' once. Therefore, Bob can lock at most (k-1) '1', so the array must have k '1' to compensate. From there, just search out for the solution!

Can someone tell me what is wrong with my modular arithmetic please? https://codeforces.me/contest/1749/submission/177211216 I got the algorithm done with 30 minutes left, then spent the rest of the time trying all combinations and figuring out how my modular arithmetic is wrong...