結果
問題 | No.2202 贅沢てりたまチキン |
ユーザー | ntuda |
提出日時 | 2023-02-05 13:41:53 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,276 bytes |
コンパイル時間 | 80 ms |
コンパイル使用メモリ | 10,880 KB |
実行使用メモリ | 95,088 KB |
最終ジャッジ日時 | 2023-09-17 06:15:34 |
合計ジャッジ時間 | 4,483 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 13 ms
95,088 KB |
testcase_01 | AC | 13 ms
8,416 KB |
testcase_02 | AC | 12 ms
8,204 KB |
testcase_03 | AC | 13 ms
8,220 KB |
testcase_04 | AC | 15 ms
8,164 KB |
testcase_05 | AC | 14 ms
8,408 KB |
testcase_06 | AC | 14 ms
8,164 KB |
testcase_07 | AC | 14 ms
8,204 KB |
testcase_08 | AC | 14 ms
8,344 KB |
testcase_09 | AC | 14 ms
8,204 KB |
testcase_10 | AC | 133 ms
49,136 KB |
testcase_11 | AC | 15 ms
8,204 KB |
testcase_12 | AC | 14 ms
8,216 KB |
testcase_13 | AC | 14 ms
8,344 KB |
testcase_14 | TLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
ソースコード
import sys sys.setrecursionlimit(200050) def find(x): if P[x] == x: return x else: P[x] = find(P[x]) #経路圧縮 return P[x] # return find(P[x]) #経路圧縮なし def same(x,y): return find(x) == find(y) def unite(x,y): x = find(x) y = find(y) if x == y: return 0 if x > y: x,y = y,x P[y] = x def parents(): Ps = set() for i in range(N): a = find(i) if a not in Ps: Ps.add(a) return Ps N,M = map(int,input().split()) AB = [list(map(int,input().split())) for _ in range(M)] P = [i for i in range(N)] visited = [False] * N E = [[] for _ in range(N)] for a,b in AB: a -= 1; b -= 1 E[a].append(b) E[b].append(a) unite(a,b) Ps = parents() def dfs(u,p): for v in E[u]: if v != p: if v in P1: if (len(P1) - P1.index(v)) % 2 == 1: return True else: return False P1.append(v) visited[v] = True if dfs(v,u): return True P1.pop(-1) visited[v] = False return False for i in Ps: P1 = [i] visited[i] = True if dfs(i,-1) == False: print("No") exit() print("Yes")