| Task: | Coloring |
| Sender: | Very Competitive Programmers |
| Submission time: | 2025-11-08 16:21:46 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.05 s | details |
| #2 | ACCEPTED | 0.77 s | details |
| #3 | ACCEPTED | 0.92 s | details |
| #4 | ACCEPTED | 0.93 s | details |
| #5 | ACCEPTED | 0.05 s | details |
| #6 | ACCEPTED | 0.05 s | details |
| #7 | ACCEPTED | 0.05 s | details |
| #8 | ACCEPTED | 0.05 s | details |
| #9 | ACCEPTED | 0.12 s | details |
| #10 | ACCEPTED | 0.33 s | details |
| #11 | RUNTIME ERROR | 0.87 s | details |
| #12 | TIME LIMIT EXCEEDED | -- | details |
| #13 | TIME LIMIT EXCEEDED | -- | details |
| #14 | TIME LIMIT EXCEEDED | -- | details |
| #15 | ACCEPTED | 0.05 s | details |
| #16 | ACCEPTED | 0.64 s | details |
| #17 | TIME LIMIT EXCEEDED | -- | details |
| #18 | ACCEPTED | 0.05 s | details |
| #19 | RUNTIME ERROR | 0.07 s | details |
| #20 | RUNTIME ERROR | 0.55 s | details |
| #21 | ACCEPTED | 0.05 s | details |
| #22 | ACCEPTED | 0.07 s | details |
| #23 | ACCEPTED | 0.97 s | details |
| #24 | ACCEPTED | 0.11 s | details |
| #25 | ACCEPTED | 0.33 s | details |
| #26 | ACCEPTED | 0.59 s | details |
| #27 | TIME LIMIT EXCEEDED | -- | details |
Code
from heapq import *
from collections import defaultdict
ns = defaultdict(lambda: set())
n,m = input().split()
n = int(n)
m = int(m)
ds = [0] * n
for i in range(m):
u,v = input().split()
u = int(u)-1
v = int(v)-1
ns[u].add(v)
ns[v].add(u)
ds[u] += 1
ds[v] += 1
pal = [set(range(6)) for i in range(n)]
ds = [(d,i) for i, d in enumerate(ds)]
heapify(ds)
cols = [None] * n
def firstcol(taken):
for i in range(6):
if i not in taken:
return i
dsdict = [len(ns[i]) for i in range(n)]
while ds:
d,i = heappop(ds)
if cols[i] is None:
#ncols = {cols[nb] for nb in ns[i]}
#cols[i] = firstcol(ncols)
#print(i, pal[i], dsdict[i], cols[i])
cols[i] = list(pal[i])[0]
c = cols[i]
for nb in ns[i]:
dsdict[nb] -= 1
ns[nb].remove(i)
if c in pal[nb]:
pal[nb].remove(c)
heappush(ds, (dsdict[nb], nb))
print(" ".join(str(x+1) for x in cols))
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 5 6 1 2 2 3 3 1 2 4 ... |
| correct output |
|---|
| 2 3 1 2 1 |
| user output |
|---|
| 1 3 2 1 2 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 100000 199998 1 2 2 3 3 4 4 5 ... |
| correct output |
|---|
| 4 3 2 3 2 3 2 3 2 3 2 3 2 3 2 ... |
| user output |
|---|
| 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 81251 200000 1 2 2 3 3 4 4 5 ... |
| correct output |
|---|
| 3 2 1 4 1 4 1 3 2 4 3 2 1 5 3 ... |
| user output |
|---|
| 3 2 1 4 1 2 1 3 6 3 1 2 5 3 2 ... |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 81251 200000 1 6251 6251 12501 12501 18751 18751 25001 ... |
| correct output |
|---|
| 3 5 3 5 3 5 3 5 3 5 3 5 3 5 3 ... |
| user output |
|---|
| 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ... |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 2 1 1 2 |
| correct output |
|---|
| 2 1 |
| user output |
|---|
| 1 2 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 5 7 3 1 3 4 2 4 2 5 ... |
| correct output |
|---|
| 1 3 3 2 1 |
| user output |
|---|
| 1 2 2 1 3 |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 9 10 4 6 5 8 9 6 5 4 ... |
| correct output |
|---|
| 3 2 1 1 3 2 1 1 1 |
| user output |
|---|
| 2 1 1 1 2 3 1 1 2 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 65 100 34 52 42 65 48 6 62 63 ... |
| correct output |
|---|
| 2 2 3 2 1 1 4 1 5 3 3 4 3 1 1 ... |
| user output |
|---|
| 1 1 1 4 5 2 3 2 3 3 3 2 2 1 2 ... |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 661 1000 102 270 29 1 235 291 1 28 ... |
| correct output |
|---|
| 2 1 1 1 2 1 1 2 1 2 2 2 3 2 3 ... |
| user output |
|---|
| 3 3 1 4 3 5 4 1 5 4 1 3 2 2 2 ... |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 6658 10000 6255 6351 6240 811 5121 5120 562 563 ... |
| correct output |
|---|
| 3 3 1 1 2 2 1 2 3 1 3 3 2 1 2 ... |
| user output |
|---|
| 5 2 5 5 3 6 3 4 3 4 3 3 4 2 4 ... |
Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 66713 100002 17616 53797 36477 36478 9289 9288 30331 12908 ... |
| correct output |
|---|
| 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 42, in <module>
cols[i] = list(pal[i])[0]
IndexError: list index out of rangeTest 12
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 133153 199900 84918 102523 65880 121666 112752 112751 119806 92639 ... |
| correct output |
|---|
| 1 3 1 1 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| (empty) |
Test 13
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 132902 199904 38449 38448 103004 31700 24769 12112 102436 54041 ... |
| correct output |
|---|
| 1 1 2 1 1 3 1 2 1 1 1 1 1 1 1 ... |
| user output |
|---|
| (empty) |
Test 14
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 133659 199900 106579 112407 107263 107093 11493 44214 15803 15804 ... |
| correct output |
|---|
| 2 2 1 1 1 2 1 1 1 1 2 1 1 2 3 ... |
| user output |
|---|
| (empty) |
Test 15
Verdict: ACCEPTED
| input |
|---|
| 36 85 28 29 8 9 36 30 14 8 ... |
| correct output |
|---|
| 1 3 2 1 3 2 3 2 1 3 2 1 2 1 3 ... |
| user output |
|---|
| 1 2 1 2 3 1 2 3 4 3 1 2 1 4 1 ... |
Test 16
Verdict: ACCEPTED
| input |
|---|
| 40000 119201 16810 16610 34321 34120 38157 37956 24084 23883 ... |
| correct output |
|---|
| 3 2 1 3 2 1 3 2 1 3 2 1 3 2 1 ... |
| user output |
|---|
| 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
Test 17
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80000 199993 29955 9954 47408 27408 51231 51232 37204 37205 ... |
| correct output |
|---|
| 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ... |
| user output |
|---|
| (empty) |
Test 18
Verdict: ACCEPTED
| input |
|---|
| 15 35 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 2 1 3 2 4 5 2 3 4 3 2 4 3 2 1 |
| user output |
|---|
| 1 4 2 1 5 3 1 6 2 1 3 1 2 3 4 |
Test 19
Verdict: RUNTIME ERROR
| input |
|---|
| 143 352 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 3 4 1 5 2 1 4 5 1 2 4 3 2 1 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 42, in <module>
cols[i] = list(pal[i])[0]
IndexError: list index out of rangeTest 20
Verdict: RUNTIME ERROR
| input |
|---|
| 81256 198855 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 3 4 1 5 2 1 4 5 1 2 4 3 2 1 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 42, in <module>
cols[i] = list(pal[i])[0]
IndexError: list index out of rangeTest 21
Verdict: ACCEPTED
| input |
|---|
| 15 33 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 1 3 2 4 3 2 1 3 5 4 3 2 1 2 |
| user output |
|---|
| 1 3 1 2 4 1 2 1 3 1 4 2 3 5 2 |
Test 22
Verdict: ACCEPTED
| input |
|---|
| 137 326 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 1 3 2 4 3 2 1 3 5 4 3 2 1 2 ... |
| user output |
|---|
| 2 2 1 3 4 1 3 1 2 1 4 2 3 5 1 ... |
Test 23
Verdict: ACCEPTED
| input |
|---|
| 82312 198211 3 2 3 4 4 2 5 4 ... |
| correct output |
|---|
| 1 1 3 2 4 3 2 1 3 5 4 3 2 1 2 ... |
| user output |
|---|
| 2 2 1 3 4 1 3 1 2 1 4 2 3 5 1 ... |
Test 24
Verdict: ACCEPTED
| input |
|---|
| 512 1025 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 2 1 2 5 1 3 4 2 1 2 1 4 3 3 3 ... |
| user output |
|---|
| 1 2 6 3 2 5 4 2 3 2 3 4 1 1 1 ... |
Test 25
Verdict: ACCEPTED
| input |
|---|
| 15342 30761 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 1 3 2 5 1 3 4 2 1 2 1 4 1 1 1 ... |
| user output |
|---|
| 3 2 6 3 2 5 4 2 3 2 3 4 1 1 1 ... |
Test 26
Verdict: ACCEPTED
| input |
|---|
| 51148 102547 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 1 3 2 5 1 3 4 2 1 2 1 4 1 1 1 ... |
| user output |
|---|
| 3 2 6 3 2 5 4 2 3 2 3 4 1 1 1 ... |
Test 27
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 99735 199964 2 13 13 3 2 14 14 3 ... |
| correct output |
|---|
| 1 3 2 5 1 3 4 2 1 2 1 4 1 1 1 ... |
| user output |
|---|
| (empty) |
