Finally made it throughout a year! Congratulations to me!
It seems that the page can be different in different time zones, so it is quite normal if what you see isn't this graph. (FYI, I'm currently in China.)
Wish things will be better!
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Finally made it throughout a year! Congratulations to me!
It seems that the page can be different in different time zones, so it is quite normal if what you see isn't this graph. (FYI, I'm currently in China.)
Wish things will be better!
I was practicing when I came across this problem. And I submitted a few codes which are almost the same, but their running time is quite different. Here's the thing:
The fastest one is here, which only runs 1590ms:
n, mod = map(int, input().split())
dp = [0] * (n * (n - 1) + 1)
diff = [0] * (n * (n - 1) + 1)
msk = n * (n - 1) // 2
v = 1
wing = 0
for i in range(n):
for j in range(msk - wing, msk + wing + 1):
if dp[j]:
diff[j] += dp[j]
diff[j + (n - i - 1) + 1] -= dp[j]
cur = 0
for j in range(msk - wing, msk + wing + n - i):
cur += diff[j]
cur %= mod
dp[j] = cur
diff[j] = 0
for j in range(msk - wing, msk + wing + n - i):
if dp[j]:
diff[j - (n - i - 1)] += dp[j]
diff[j + 1] -= dp[j]
cur = 0
for j in range(msk - wing - (n - i - 1), msk + wing + n - i):
cur += diff[j]
cur %= mod
dp[j] = cur
diff[j] = 0
for j in range(-(n - i - 1), 0):
dp[j + msk] += v * (n - i + j) % mod
dp[j + msk] %= mod
v = v * (n - i) % mod
wing += n - i - 1
print(sum(dp[msk+1:]) % mod)
Yet, another code which is basically the same as the former one needs 3743ms:
def main():
n, mod = map(int, input().split())
dp = [0] * (n * (n - 1) + 1)
diff = [0] * (n * (n - 1) + 1)
msk = n * (n - 1) // 2
v = 1
wing = 0
for i in range(n):
for j in range(msk - wing, msk + wing + 1):
if dp[j]:
diff[j] += dp[j]
diff[j + (n - i - 1) + 1] -= dp[j]
cur = 0
for j in range(msk - wing, msk + wing + n - i):
cur += diff[j]
cur %= mod
dp[j] = cur
diff[j] = 0
for j in range(msk - wing, msk + wing + n - i):
if dp[j]:
diff[j - (n - i - 1)] += dp[j]
diff[j + 1] -= dp[j]
cur = 0
for j in range(msk - wing - (n - i - 1), msk + wing + n - i):
cur += diff[j]
cur %= mod
dp[j] = cur
diff[j] = 0
for j in range(-(n - i - 1), 0):
dp[j + msk] += v * (n - i + j) % mod
dp[j + msk] %= mod
v = v * (n - i) % mod
wing += n - i - 1
print(sum(dp[msk+1:]) % mod)
return
t = 1
for _ in range(t):
main()
I'm quite puzzled as these two codes seems nothing too different. I really wonder how this could happen as it could cause some unexpected TLEs in other questions. It would really help a lot if you could offer some insights on it.
Thanks in advance!
In recent competitions, I came across this type of RUNTIME ERROR. Here's the thing:
I wrote a program like this:
def main():
k = 15
m = 3
for a in range(k + 1):
for b in range(k + 1):
for c in range(min(m, k) + 1):
for d in range(min(m, k) + 1):
continue
return
t = 1
for _ in range(t):
main()
But in Atcoder, it showed something like this: (Sorry that the picture isn't clear enough)
It really bothered me and I wonder if anyone could be so kind as to help me with this issue.
(p.s. The RUNTIME ERROR doesn't show in Codeforces, so I'm really confused)
Here are some codes that don't show RUNTIME ERROR:
k = 15
m = 3
for a in range(k + 1):
for b in range(k + 1):
for c in range(min(m, k) + 1):
for d in range(min(m, k) + 1):
pass
def main():
k = 15
m = 3
for a in range(k + 1):
for b in range(k + 1):
for c in range(min(m, k) + 1):
for d in range(min(m, k) + 1):
print(d)
return
t = 1
for _ in range(t):
main()
Name |
---|