結果

問題 No.2536 同値性と充足可能性
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-11-10 22:20:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 4,740 ms
コンパイル使用メモリ 268,112 KB
実行使用メモリ 14,980 KB
最終ジャッジ日時 2023-11-10 22:20:55
合計ジャッジ時間 6,937 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 8 ms
6,676 KB
testcase_21 AC 9 ms
6,676 KB
testcase_22 AC 9 ms
6,676 KB
testcase_23 AC 85 ms
11,128 KB
testcase_24 AC 83 ms
10,104 KB
testcase_25 AC 110 ms
14,596 KB
testcase_26 AC 109 ms
14,212 KB
testcase_27 AC 112 ms
14,980 KB
testcase_28 AC 106 ms
13,572 KB
testcase_29 AC 107 ms
13,700 KB
testcase_30 AC 107 ms
13,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main () {
	int N, M;
	cin >> N >> M;
	two_sat T(N);
	while (M--) {
		int a, b;
		string s;
		cin >> a >> s >> b;
		a --; b --;
		bool x = s == "<==>";
		T.add_clause(a, true, b, !x);
		T.add_clause(a, false, b, x);
	}
	bool ok = T.satisfiable();
	if (!ok) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		auto V = T.answer();
		int s = 0;
		for (auto b : V) {
			s += b;
		}
		bool tt = s * 2 >= N;
		cout << max(s, N - s) << endl;
		std::vector<int> A;
		for (int i = 0; i < N; i ++) {
			if (V[i] == tt) {
				A.push_back(i + 1);
			}
		}
		for (auto a : A) {
			cout << a << (a == A.back() ? "" : " ");
		}
		cout << endl;
	}
}
0