結果

問題 No.3552 Triangular Coloring
コンテスト
ユーザー nikoro256
提出日時 2026-05-23 00:08:03
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 691 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 355 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 169,216 KB
最終ジャッジ日時 2026-05-23 00:08:11
合計ジャッジ時間 7,017 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 RE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque
N,M=map(int,input().split())
l = [{0,1,2,3} for _ in range(N)]
edge = [[] for _ in range(N)]
for _ in range(M):
    u,v = map(int,input().split())
    edge[u-1].append(v-1)
    edge[v-1].append(u-1)
# 順番がわかれば構成めっちゃ簡単なんだけどなああああああ
pos = 0
ans = [-1]*N
dq = deque()
dq.append(pos)
use = [False]*N
use[0] = True
while dq:
    p = dq.popleft()
    if len(l[pos]) == 0:
        assert 0==1
    ans[p] = list(l[p])[0]
    for e in edge[p]:
        if ans[p] in l[e]:
            l[e].remove(ans[p])
        if not use[e]:
            use[e] = True
            dq.append(e)
print("Yes")
print(*[ai+1 for ai in ans])
0