結果
問題 |
No.3056 Disconnected Coloring
|
ユーザー |
![]() |
提出日時 | 2025-03-14 22:05:04 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,068 bytes |
コンパイル時間 | 296 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 151,904 KB |
最終ジャッジ日時 | 2025-03-14 22:05:25 |
合計ジャッジ時間 | 19,272 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 1 |
other | AC * 15 WA * 14 RE * 5 |
ソースコード
import sys input = sys.stdin.readline N,M=map(int,input().split()) EDGE=[list(map(int,input().split())) for i in range(M)] for i in range(M): EDGE[i][0]-=1 EDGE[i][1]-=1 E=[[] for i in range(N)] for i in range(M): x,y=EDGE[i] E[x].append((y,i)) E[y].append((x,i)) ANS=["R"]*M NOW=0 Q=[0] USE=[0]*N USE[0]=1 while Q: x=Q.pop() for to,ind in E[x]: if to==N-1: continue if ANS[ind]=="R" and NOW<M//2: ANS[ind]="B" if USE[to]==0: Q.append(to) USE[to]=1 NOW+=1 if ANS.count("R")==ANS.count("B"): print("".join(ANS)) exit() ANS=["R"]*M NOW=0 Q=[N-1] USE=[0]*N USE[N-1]=1 while Q: x=Q.pop() for to,ind in E[x]: if to==0: continue if ANS[ind]=="R" and NOW<M//2: ANS[ind]="B" if USE[to]==0: Q.append(to) USE[to]=1 NOW+=1 if ANS.count("R")==ANS.count("B"): print("".join(ANS)) exit() XXX=[i for i in range(1<<(1<<2000))]