# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
590333 |
2022-07-05T20:49:28 Z |
dnialh |
Rope (JOI17_rope) |
PyPy 3 |
|
60 ms |
20260 KB |
from collections import Counter
import sys as sus
input = sus.stdin.readline
n, m = map(int, input().split())
#c = list(map(int, input().split()))
c = list(range(1, m + 1))
ct = Counter(c)
ctl = [0] * (m + 1)
for i in range(1, m + 1):
ctl[i] = ct[i]
o = ct.most_common()
del ct
odd = Counter()
eve = Counter()
for i in range(n - 1):
s = min(c[i], c[i + 1])
b = max(c[i], c[i + 1])
if i % 2:
odd[(s << 20) | b] += 1
else:
eve[(s << 20) | b] += 1
out = []
for i in range(1, m + 1):
res = 0
for v, vc in o:
if v == i:
continue
bl = odd[(i << 20) | v] + odd[v << 20 | i]
br = eve[(i << 20) | v] + eve[v << 20 | i]
bad = min(bl, br)
res = max(res, vc - bad)
if bad == 0:
break
out.append(n - res - ctl[i])
print('\n'.join(map(str, out)))
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
60 ms |
20260 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
60 ms |
20260 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
60 ms |
20260 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
60 ms |
20260 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
60 ms |
20260 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |