| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | jiangly | 3670 |
| 3 | Kevin114514 | 3657 |
| 4 | maroonrk | 3355 |
| 5 | Um_nik | 3353 |
| 6 | squareOf105 | 3346 |
| 7 | tourist | 3343 |
| 8 | strapple | 3324 |
| 9 | heuristica | 3322 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | AmShZ | 143 |
| 5 | Um_nik | 141 |
| 6 | Errichto | 139 |
| 7 | adamant | 137 |
| 8 | BledDest | 133 |
| 8 | maroonrk | 133 |
| 10 | qwexd | 130 |
|
0
Modular operations are expensive. And even if they weren't, the first solution already took nearly 2s and adding more operations there inside the loop would yield TLE. |
|
0
It's not a random guessing problem. Notice that the difference is between 1 and $$$n^2-1$$$, so naturally we first try to get them all. For $$$n^2-1$$$, $$$n^2$$$ and 1 need to be adjacent, then for $$$n^2-2$$$, either $$$n^2$$$ and $$$2$$$ or $$$n^2-1$$$ and $$$1$$$ need to be adjacent, .... It's quite easy to achieve that. If you know gray code, Z-order, or something like those, easier. |
|
+11
You can calculate the inverses of factorials more efficiently by calculating them from n to 0. |
|
0
Wow.. That was the reason I couldn't get AC. I thought I could choose the order of operations. |
|
0
1 1 100 10 -> ... -> 100 100 100 10 -> ... -> 100 100 100 100 |
|
+6
There was hardly any implementation before E ... |
|
0
I have no idea how to interpret dp when you put k in the inner loop. In Floyd-Warshall, k represents the intermediate vertex, i.e., the algorithm updates dp when it finds a shorter path passing through k. |
|
0
Wow... I was thinking and thinking with that misunderstanding of the first operation for the whole contest. I got to read the statement a bit more carefully. |
|
+3
Oh, I see the issue now. You are not using std::abs. Either use std::abs or llabs. |
|
0
I guess the round could have been better if the problem E had an easier version with lower constraints... |
|
+1
I don't know, my submission got passed just fine with abs. |
|
+3
minu = m % MOD. But seriously, the diagnostics message is already pointing the exact problematic line in this case. It doesn't make sense that you can't debug this. |
|
+3
That is not even a valid placement of cacti. Probably the issue of most WA submissions was one-directional dp, while we needed bfs. |
|
0
Change n, m, ans, etc to long long, then I guess it will be fine. What about wiki page? https://en.wikipedia.org/wiki/Modular_arithmetic Or you can just read the intro section of any elementary number theory book. |
|
0
Thanks a lot. |
|
0
No, you are still multiplying by m/2. You need to do minu *= (m/2)%MOD; minu %= MOD. In the end, you also need ans %= MOD before if(ans<0) |
|
+7
The issue is the range of m. For example, you multiply by m/2. Use (m/2)%MOD instead. |
|
+6
Yeah, I tried many examples for last 30 mins but couldn't really figure out the counter example. I wish I could see the test 2 now... |
|
+10
So cool E and F! |
|
0
Yeah, I was quite smiling when I read FTL :) |
|
0
Well, your logic needs extra 0 at the end of s. |
|
0
Assuming you meant to fail to solve any problems, knowing arrays, sortings, and elementary maths is usually enough for first problems. |
| Name |
|---|


