結果

問題 No.1436 Rgaph
ユーザー chineristACchineristAC
提出日時 2021-03-19 23:25:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 995 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 79,884 KB
最終ジャッジ日時 2024-04-29 19:15:57
合計ジャッジ時間 6,570 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
56,672 KB
testcase_01 AC 44 ms
56,356 KB
testcase_02 AC 45 ms
57,232 KB
testcase_03 AC 42 ms
56,412 KB
testcase_04 AC 45 ms
56,304 KB
testcase_05 WA -
testcase_06 AC 129 ms
78,340 KB
testcase_07 AC 44 ms
55,960 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 51 ms
59,364 KB
testcase_12 AC 49 ms
59,908 KB
testcase_13 AC 48 ms
59,528 KB
testcase_14 AC 54 ms
67,616 KB
testcase_15 AC 47 ms
58,392 KB
testcase_16 AC 54 ms
67,612 KB
testcase_17 AC 60 ms
70,700 KB
testcase_18 AC 58 ms
70,136 KB
testcase_19 AC 62 ms
70,772 KB
testcase_20 AC 111 ms
77,528 KB
testcase_21 AC 97 ms
77,620 KB
testcase_22 AC 178 ms
78,688 KB
testcase_23 AC 155 ms
78,272 KB
testcase_24 AC 192 ms
78,444 KB
testcase_25 AC 255 ms
78,820 KB
testcase_26 AC 262 ms
78,920 KB
testcase_27 AC 277 ms
79,120 KB
testcase_28 WA -
testcase_29 AC 225 ms
79,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,M = mi()
edge = [[] for i in range(N)]
for _ in range(M):
    a,b = mi()
    edge[a-1].append(b-1)

for s in range(N):
    visit = [[False,False] for i in range(N)]
    visit[s][0] = True
    stack = [(s,0)]
    while stack:
        v,p = stack.pop()
        for nv in edge[v]:
            if not visit[nv][1-p]:
                visit[nv][1-p] = True
                stack.append((nv,1-p))
    if any(not visit[i][0] for i in range(N)):
        exit(print(-1))

ans = ["R"] * (M//2) + ["G"] * (M//2)
if M%2:
    ans += ["R"]

p = [-1 for i in range(N)]
for i in range(N):
    if len(edge[i])==1:
        p[i] = edge[i][0]
    else:
        break
else:
    exit(print(-1))

random.shuffle(ans)
print("".join(ans))
0