結果

問題 No.2536 同値性と充足可能性
ユーザー ニックネームニックネーム
提出日時 2023-11-10 22:43:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 647 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 40,192 KB
最終ジャッジ日時 2023-11-10 22:43:59
合計ジャッジ時間 7,448 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 28 ms
10,112 KB
testcase_02 AC 28 ms
10,112 KB
testcase_03 AC 28 ms
10,112 KB
testcase_04 AC 28 ms
10,112 KB
testcase_05 AC 28 ms
10,112 KB
testcase_06 AC 28 ms
10,112 KB
testcase_07 AC 28 ms
10,112 KB
testcase_08 AC 28 ms
10,112 KB
testcase_09 AC 28 ms
10,112 KB
testcase_10 AC 32 ms
10,112 KB
testcase_11 AC 27 ms
10,112 KB
testcase_12 AC 28 ms
10,112 KB
testcase_13 AC 27 ms
10,112 KB
testcase_14 AC 28 ms
10,112 KB
testcase_15 AC 28 ms
10,112 KB
testcase_16 AC 28 ms
10,112 KB
testcase_17 AC 32 ms
10,240 KB
testcase_18 AC 32 ms
10,240 KB
testcase_19 AC 28 ms
10,112 KB
testcase_20 AC 56 ms
10,496 KB
testcase_21 AC 59 ms
11,008 KB
testcase_22 AC 58 ms
11,008 KB
testcase_23 AC 352 ms
19,968 KB
testcase_24 AC 380 ms
20,352 KB
testcase_25 AC 612 ms
40,064 KB
testcase_26 AC 647 ms
39,808 KB
testcase_27 AC 630 ms
39,936 KB
testcase_28 AC 644 ms
39,808 KB
testcase_29 AC 630 ms
39,936 KB
testcase_30 AC 607 ms
40,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
adj = [[] for _ in range(n)]
ban = [[] for _ in range(n)]
g = [-1]*n
for _ in range(m):
    i,e,j = input().split()
    i,j = int(i)-1,int(j)-1
    if e=="<==>": adj[i].append(j); adj[j].append(i)
    else: ban[i].append(j); ban[j].append(i)
for i in range(n):
    if g[i]!=-1: continue
    g[i] = 0; st = [i]
    while st:
        p = st.pop()
        for c in adj[p]:
            if g[c]==-1: g[c] = g[p]; st.append(c)
            elif g[c]!=g[p]: exit(print("No"))
        for c in ban[p]:
            if g[c]==-1: g[c] = g[p]^1; st.append(c)
            elif g[c]==g[p]: exit(print("No"))
a = [i+1 for i in range(n) if g[i]==0]
b = [i+1 for i in range(n) if g[i]==1]
print("Yes"); print(max(len(a),len(b)))
print(*a if len(b)<=n//2 else b)
0