結果
問題 | No.2536 同値性と充足可能性 |
ユーザー | flygon |
提出日時 | 2023-11-10 22:12:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 357 ms / 2,000 ms |
コード長 | 1,479 bytes |
コンパイル時間 | 863 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 106,600 KB |
最終ジャッジ日時 | 2023-11-10 22:12:10 |
合計ジャッジ時間 | 5,713 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
55,728 KB |
testcase_01 | AC | 44 ms
55,728 KB |
testcase_02 | AC | 44 ms
55,728 KB |
testcase_03 | AC | 48 ms
55,728 KB |
testcase_04 | AC | 45 ms
55,728 KB |
testcase_05 | AC | 45 ms
55,728 KB |
testcase_06 | AC | 44 ms
55,728 KB |
testcase_07 | AC | 45 ms
55,728 KB |
testcase_08 | AC | 44 ms
55,728 KB |
testcase_09 | AC | 49 ms
55,728 KB |
testcase_10 | AC | 45 ms
55,728 KB |
testcase_11 | AC | 44 ms
55,728 KB |
testcase_12 | AC | 44 ms
55,728 KB |
testcase_13 | AC | 46 ms
55,728 KB |
testcase_14 | AC | 45 ms
55,728 KB |
testcase_15 | AC | 45 ms
55,728 KB |
testcase_16 | AC | 45 ms
55,728 KB |
testcase_17 | AC | 57 ms
66,772 KB |
testcase_18 | AC | 56 ms
66,772 KB |
testcase_19 | AC | 45 ms
55,728 KB |
testcase_20 | AC | 68 ms
73,320 KB |
testcase_21 | AC | 78 ms
77,032 KB |
testcase_22 | AC | 79 ms
77,032 KB |
testcase_23 | AC | 207 ms
86,792 KB |
testcase_24 | AC | 194 ms
86,676 KB |
testcase_25 | AC | 343 ms
105,072 KB |
testcase_26 | AC | 352 ms
103,160 KB |
testcase_27 | AC | 357 ms
106,600 KB |
testcase_28 | AC | 328 ms
102,520 KB |
testcase_29 | AC | 336 ms
103,536 KB |
testcase_30 | AC | 336 ms
102,772 KB |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd from collections import defaultdict n,m = map(int,input().split()) graph = [[] for i in range(n+1)] for i in range(m): u, e, v = map(str,input().split()) u = int(u) v = int(v) if e == "<=/=>": graph[u].append((v,1)) graph[v].append((u,1)) else: graph[u].append((v,0)) graph[v].append((u,0)) depth = [-1]*(n+1) def bfs(s, n): que = deque([s]) depth[s] = 0 ok = 1 ss = set() while que: crr = que.popleft() ss.add(crr) for nxt,w in graph[crr]: if depth[nxt] == -1: depth[nxt] = depth[crr]^w que.append(nxt) else: if depth[nxt] != depth[crr]^w: ok = 0 return ok, ss big = [] ok = 1 for i in range(1, n+1): if depth[i] != -1: continue oki, s = bfs(i, n) ok &= oki o = [] z = [] for j in s: if depth[j] == 1: o.append(j) elif depth[j] == 0: z.append(j) if len(o) > len(z): big += o else: big += z if not ok: print('No') else: for i in range(1, n+1): if depth[i] == -1: big.append(i) print('Yes') big.sort() print(len(big)) print(*big)