結果
問題 | No.1436 Rgaph |
ユーザー | chineristAC |
提出日時 | 2021-03-19 23:20:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 850 bytes |
コンパイル時間 | 392 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 79,272 KB |
最終ジャッジ日時 | 2024-04-29 19:02:56 |
合計ジャッジ時間 | 6,551 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
55,808 KB |
testcase_01 | AC | 42 ms
55,552 KB |
testcase_02 | AC | 43 ms
55,552 KB |
testcase_03 | AC | 43 ms
55,680 KB |
testcase_04 | AC | 42 ms
55,424 KB |
testcase_05 | AC | 44 ms
55,552 KB |
testcase_06 | AC | 127 ms
78,208 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 51 ms
58,496 KB |
testcase_12 | AC | 51 ms
58,496 KB |
testcase_13 | AC | 50 ms
58,496 KB |
testcase_14 | AC | 59 ms
67,200 KB |
testcase_15 | AC | 50 ms
57,856 KB |
testcase_16 | AC | 60 ms
67,200 KB |
testcase_17 | AC | 67 ms
70,400 KB |
testcase_18 | AC | 66 ms
69,120 KB |
testcase_19 | AC | 66 ms
69,504 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 182 ms
78,304 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 258 ms
78,976 KB |
testcase_26 | AC | 274 ms
78,592 KB |
testcase_27 | AC | 277 ms
79,108 KB |
testcase_28 | WA | - |
testcase_29 | AC | 213 ms
79,272 KB |
ソースコード
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: exit(print(-1)) random.shuffle(ans) print("".join(ans))