結果

問題 No.2536 同値性と充足可能性
ユーザー flygonflygon
提出日時 2023-11-10 22:00:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,319 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 103,400 KB
最終ジャッジ日時 2023-11-10 22:00:48
合計ジャッジ時間 5,502 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,728 KB
testcase_01 AC 41 ms
55,728 KB
testcase_02 AC 42 ms
55,728 KB
testcase_03 AC 42 ms
55,728 KB
testcase_04 AC 41 ms
55,728 KB
testcase_05 AC 42 ms
55,728 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 42 ms
55,728 KB
testcase_10 AC 41 ms
55,728 KB
testcase_11 AC 41 ms
55,728 KB
testcase_12 AC 43 ms
55,728 KB
testcase_13 AC 42 ms
55,728 KB
testcase_14 AC 42 ms
55,728 KB
testcase_15 AC 42 ms
55,728 KB
testcase_16 AC 42 ms
55,728 KB
testcase_17 AC 53 ms
66,776 KB
testcase_18 AC 53 ms
66,776 KB
testcase_19 WA -
testcase_20 AC 61 ms
73,320 KB
testcase_21 AC 66 ms
74,344 KB
testcase_22 AC 73 ms
77,032 KB
testcase_23 AC 155 ms
86,408 KB
testcase_24 AC 158 ms
86,292 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 217 ms
103,400 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 213 ms
103,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))

def bfs(s, n):
    que = deque([s])
    depth = [-1]*(n+1)
    pre = [-1]*(n+1)
    depth[s] = 0
    ok = 1
    while que:
        crr = que.popleft()
        for nxt,w in graph[crr]:
            if depth[nxt] == -1:
                depth[nxt] = depth[crr]^w
                pre[nxt] = crr
                que.append(nxt)
            else:
                if depth[nxt] != depth[crr]^w:
                    ok = 0

    return ok, depth
ok, d = bfs(1, n)
if not ok:
    print('No')
else:
    z = []
    o = []
    for i in range(1, n+1):
        if d[i] == 1:
            o.append(i)
        else:
            z.append(i)
    print("Yes")
    if len(o) > len(z):
        print(len(o))
        print(*o)
    else:
        print(len(z))
        print(*z)
0