Comments
On Lydeoverwhelmed, 3 years ago
+3

da. god

good luck on your journey

you used a 64-bit compiler, so it made sense that long long runs faster than int

+30

take ratio by the number of participants then

Would you be nice to explain your solution? thanks in advance

What is the solution to P6? I tried to random shuffle the input, then generate all subset sum of the first 19 elements and the last 19 elements but it failed on around 7 tests. Here is my code:

Code

Thanks in advance!

in fact, 2*x mod a = 2*x - a < x

So we need to calculate $$$n^ {\frac{d}{2}} \bmod p$$$ where $$$d = (a_1 + 1) \times (a_2 + 1) \times \ldots \ (a_k + 1)$$$.

The problem here is $$${\frac{d}{2}}$$$. If $$$d$$$ is odd, then it will be hard for us to calculate, but $$$d$$$ is odd only if all $$$a_i + 1$$$ is odd, which means all $$$a_i$$$ is even, then $$$n$$$ is a square number and ... (like my explanation above).

So now, $$$d$$$ is even, and we can find some $$$a_i + 1$$$ that is even, then $$$d = (a_1 + 1) \times (a_2 + 1) \ldots \times ((a_i + 1) / 2) \ldots \times (a_k + 1)$$$.

Hope that makes sense.

In problem E you can also just simulate all their moves:

My code

ChthollyNotaSeniorious there is some problem with markup in the solution for D

that hacker must be smart though, so you couldn't go and hacked other people that he would then hacked

probably because push_back is slow

When will we be able to upsolve the problems? Thanks!

Hints for Prijateljice? Seems like it is not too hard according to the number of solve in the leaderboard. I thought of some dp but it leads to nowhere. Thanks~!

How to solve "Lampice"? Thanks!

+2

for even you can also print 1, n + 1, n + 1, ...

Can you please elaborate, maybe some proof or insights?

How does you get $$$dp[i] =\Sigma dp[j]$$$ in the first case and why the answer in the second case is the chain?

A simpler solution with less math for D:

We need to calculate $$$n^ {\frac{d}{2}} \bmod p$$$ where $$$d$$$ is the count of divisors of $$$n$$$ (this is actually still true even if $$$d$$$ is odd).

And as we all know, if $$$n = p_1^{a_1} \times p_2^{a_2} \times \ldots \times p_k^{a_k}$$$ then $$$d = (a_1 + 1) \times (a_2 + 1) \times \ldots \ (a_k + 1)$$$.

If any of $$$a_i$$$ is odd then we can divide the first $$$a_i + 1$$$ by 2 and then calculate normally.

Else every $$$a_i$$$ is even, i.e. $$$n$$$ is a square number, and we can use this fact to remove the $$$/2$$$ from $$$d/2$$$. Let $$$n = x^2$$$, then $$$n^\frac{d}{2} \Leftrightarrow (x^2)^{\frac{d}{2}} \Leftrightarrow x^{2\times \frac{d}{2}} \Leftrightarrow x^d$$$.

My (not so clean) implementation: 161385006.

Actually it's possible not to precalculate, since you can find $$$C$$$ closest to $$$c$$$ can be found in $$$O(1)$$$ and $$$B$$$ closest to $$$b$$$ in $$$O(\sqrt{B})$$$ which is roughly $$$1e8$$$ operations maximum. 155903580

great solution :3

Thanks! That implementation was so elegant :orz:

One small question tho, what do a, b, c, d do here:

    a=min(a,i-j),b=max(b,i-j);
    c=min(c,i+j),d=max(d,i+j);

I know that they will help you to calculate the area of the diamond (if it is), but I don't know how does it relate to i+j and i-j.

What is your implementation for B? I rotated the table by 45 degrees and then it can be easily solved, but it wasn't short at all.

i got the idea from that problem too :v

you don't really need binary search tho

Lmao, I solved CNTFRAC by calculating number of solutions to $$$wz + xy = kxz$$$ (took around 500s) and then store the answer in an array.

Brute force code
On Mr_DiceWhy am I getting TLE?, 5 years ago
0

yes, it's simply faster

On Mr_DiceWhy am I getting TLE?, 5 years ago
0

use Pypy 3 instead of Python 3 and it's AC 147543377

On MangoosteGlobal Round 19 Editorial, 5 years ago
0

Currently, your code MLE at test 77 146344541, is your approach wrong or you didn't implement it neatly?

0

thanks!

r - l + 1 is the number of numbers in [l, r]

r / 2 is the number of even numbers in [1, r]

(l - 1) / 2 is the number of even numbers in [1, l - 1]

so (r / 2) - ((l - 1) / 2) is the number of even numbers in [l, r]

subtracts the number of even numbers from the total number of numbers -> you get number of odd numbers

Wow, this solution is surprisingly simple, can you explain why this would works? Thanks.

How to solve Break the Balance?

Why is the pairing in 1618D - Array and Operations optimal? It seems obvious but I can't find a proof for it.

change bool solve() to void solve() and it's AC

maybe pseudocode would be nice, and comments will only be for shortcuts and tricks

it would be very interesting to see the code for the $$$O(n)$$$ solution

-21

C is trash.

seems like there is some problem with the formatting Errichto

To make your code cleaner, you can use array<ll, 4> instead of those pairs, here is the AC code with that modification 131514905

Sorry for necroposting but in the "Range distinct query (SPOJ DQUERY)" part, shouldn't the $$$pre[r + 1] \lt l$$$ be $$$pre[a[r + 1]] \lt l$$$ (and similarly for $$$r \lt nxt[l - 1]$$$), where $$$a$$$ is our array? box

On hmehtaThank You! :), 5 years ago
+7

thank you

On ResendeWeird Codeforces Bug, 5 years ago
0

imagine fst because of this bug...

On ICPCNewsICPC World Finals Moscow, 5 years ago
+495

On gnudgnaohDigit DP "tricks", 5 years ago
0

I just take that as an example for a slow solution that wouldn't AC.

On gnudgnaohDigit DP "tricks", 5 years ago
0

Can you provide the statement(or even better, links) for the COCI problems? And can you provide some examples about the DP over a digit DP part? Thanks!

On gnudgnaohDigit DP "tricks", 5 years ago
0

thanks for taking your time reading this blog, hope it helped you and as always jalsol orz

On gnudgnaohDigit DP "tricks", 5 years ago
0

Auto comment: topic has been updated by gnudgnaoh (previous revision, new revision, compare).

On gnudgnaohDigit DP "tricks", 5 years ago
0

Auto comment: topic has been updated by gnudgnaoh (previous revision, new revision, compare).

Well, at least F has a different output format. https://cses.fi/problemset/task/1133

Green is when the edge is oriented downwards. After you go from vert to root using the red path, now you are at the root, and from the root, you can only go downwards to other vertexes.

"Observe that all edges outside the path from the root to vert should turn green, and those on the path should turn red."

I believe this is because we will go upwards from the vert to the root (thus, all nodes must be red on the path), and from the root we will go out to other vertexes (thus, all nodes outside the path must be green).

The formula can be rewritten as:

  RedEntireTree — 2*RedOnPath[vert] + RootDistance[vert]
= (RedEntireTree - RedOnPath[vert]) + (RootDistance[vert] - RedOnPath[vert])
=           RedOutsidePath          +            GreenOnPath

You should ask if the ICPC WF Invitational Division can be rescheduled to not conflict with CF rounds.

Now this is REAL contribution.

The quality of problems of Codechef is incredibly high nowadays. Thank you Um_nik.

O(N) solution for problem B div 2 (1020B - Badge) for those interested:

code

Wow, only now that I notice problem H of this contest is rated 3295 on kenkoooo.com. Idk but that seems quite high for a contest for beginners :v

can you elaborate on the intersection part? (what is lto, lfrom, ...)

0

Does anybody have problems that can be solved efficiently using this representation and is much better than other representations?

imagine having a supercomputer and being able to run any kind of bruteforce...

Can you still provide code for problem F? Even though it might be incomprehensible, it might be used to stress test our solutions. Or maybe you can provide some participant's code which is more readable.

bad round, no pikachu theme...

pikachu theme? sounds interesting :))

Wow, it seems like 4 out of the top 5 of div 2 are alt accounts :v

I have another solution for Chef and Closure, simply sort array a, check if a[0] * [1], a[n - 1] * a[n - 2], a[0] * a[n - 1] are all in array a. I don't know why it works though :v

use 2**62 or larger

problem F1 meme

Did anybody implement problem F in O(N) using prefix sums? I'm trying to implement it but can't deal with the indexes.

UPD:

Implemented it, code for people who need

You can also use the Google cache :v

Thanks.

Does anyone have code for generating random forests so I can test my solution for D1 before the System Test ends?

On ElegiaIOI2021 China Team, 5 years ago
-7

After IOI 2020, now I feel that China team selection is harder than IOI itself :v

Could someone explain for me the logic behind this part in the editorial code for problem G, please?

that part

I knew it was related to the multiplicativity of d(n) but I couldn't fully understand.

And this is

the whole code

Thanks in advance!

No, you should have read the statement more carefully.

+11

I wonder how many t-shirts he has had from all these global rounds and competitions...

+5

May you explain why it would run much faster?

0

Did anybody solve B using the randomization optimization mentioned in the hint in the editorial?

Only 4 different characters are needed in D2: 123522856

Idea:

So I used the exact idea that the solution mentions, however I can't figure out (for literally hours) what is wrong with my code since everything I coded seems logical. Can anyone help me please, thanks in advance!

Idea
Code

Is it possible to have the author's name and the current time (the placeholders like in the cf-tool) in the template? Right now, if I set up the template with the placeholders in the cf-tool, it won't work.

can you explain it further ?

btw, why is the condition for the for loop (k * (k + 1)) / 2 <= n but not (k * (k — 1)) / 2 <= n ?

I know this has been asked many times but please add the option to participate out of competition.

-13

wow 7 problems on a div3, this is gonna be interesting :))

The spoiler is bugged, please fix.

MikeMirzayanov Please add this option. This is so necessary when your schedule is just after a contest had started and you don't have any more time in you schedule to participate virtually.

Finally, the almost-copy-pasted-part joke is back.

I solved A in 2 min and then struggled with B for the rest of the competition, can somebody tell me CLEARLY how to solve B ? (I know it is just implementation, but how ?)

Problem C is quite similar to this problem: 1438C - Engineer Artem

On MonogonCodeforces Global Round 12, 6 years ago
0

Thanks, the editorial is also out and I can understand the relation now.

On MonogonCodeforces Global Round 12, 6 years ago
+12

the difference between a mathematician and a programmer

On MonogonCodeforces Global Round 12, 6 years ago
0

I thought of that problem but could't find the relation, can you elaborate?

On MonogonCodeforces Global Round 12, 6 years ago
+1

That difficulty jump between B and C1 tho D:

How to solve B ?

Two problems with the same solution can be rewritten and changed the way how the contestants are going to approach it. Then, the part that is hard is getting to the point where you realize that is the same problem from before.

Also, ad-hoc problems are almost impossible to run out.

No offense to the writers but I don't really think this contest is educational.

A should be a better example.

I can't believe D is just mostly implementing what they given, I overthought that so hard D:

the comment section is shit

I believe if you swap problems B and F nobody will notice and more people will have solved F.