結果
| 問題 |
No.3056 Disconnected Coloring
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-03-14 21:44:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 619 bytes |
| コンパイル時間 | 1,194 ms |
| コンパイル使用メモリ | 82,536 KB |
| 実行使用メモリ | 120,476 KB |
| 最終ジャッジ日時 | 2025-03-14 21:45:23 |
| 合計ジャッジ時間 | 6,319 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 WA * 5 TLE * 1 -- * 24 |
ソースコード
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
if M%2==1:
print(-1)
exit()
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]
while Q:
x=Q.pop()
for to,ind in E[x]:
if to==M-1:
continue
if ANS[ind]=="R" and NOW<M//2:
ANS[ind]="B"
Q.append(to)
NOW+=1
if ANS.count("R")!=M//2:
print(-1)
else:
print("".join(ANS))
titia