結果
問題 | No.3056 Disconnected Coloring |
ユーザー |
![]() |
提出日時 | 2025-03-14 21:30:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,337 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 201,776 KB |
最終ジャッジ日時 | 2025-03-14 21:30:23 |
合計ジャッジ時間 | 19,330 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 WA * 9 |
ソースコード
import sys# sys.setrecursionlimit(200005)# sys.set_int_max_str_digits(200005)int1 = lambda x: int(x)-1pDB = lambda *x: print(*x, end="\n", file=sys.stderr)p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)def II(): return int(sys.stdin.readline())def LI(): return list(map(int, sys.stdin.readline().split()))def LLI(rows_number): return [LI() for _ in range(rows_number)]def LI1(): return list(map(int1, sys.stdin.readline().split()))def LLI1(rows_number): return [LI1() for _ in range(rows_number)]def SI(): return sys.stdin.readline().rstrip()# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]# inf = -1-(-1 << 31)inf = -1-(-1 << 62)# md = 10**9+7md = 998244353n,m=LI()to=[[] for _ in range(n)]uv=[]uv2i={}for i in range(m):u,v=LI1()to[u].append(v)to[v].append(u)uv.append((u,v))uv2i[u,v]=uv2i[v,u]=iif m&1 or 0 in to[n-1] or len(to[0])*2>m or len(to[n-1])*2>m:print(-1)exit()c=[m//2,m//2]ans=[-1]*mfor v in to[0]:i=uv2i[0,v]ans[i]=0c[0]-=1for v in to[n-1]:i=uv2i[v,n-1]ans[i]=1c[1]-=1for i in range(m):if ans[i]==-1:if c[0]:ans[i]=0c[0]-=1else:ans[i]=1print("".join("RB"[c] for c in ans))