結果

問題 No.2536 同値性と充足可能性
ユーザー shobonvipshobonvip
提出日時 2023-11-10 21:35:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 1,882 bytes
コンパイル時間 4,994 ms
コンパイル使用メモリ 268,072 KB
実行使用メモリ 17,928 KB
最終ジャッジ日時 2023-11-10 21:36:07
合計ジャッジ時間 7,712 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 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 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 9 ms
6,676 KB
testcase_21 AC 10 ms
6,676 KB
testcase_22 AC 10 ms
6,676 KB
testcase_23 AC 98 ms
15,484 KB
testcase_24 AC 93 ms
12,416 KB
testcase_25 AC 120 ms
15,748 KB
testcase_26 AC 118 ms
16,264 KB
testcase_27 AC 116 ms
14,980 KB
testcase_28 AC 124 ms
17,928 KB
testcase_29 AC 113 ms
14,852 KB
testcase_30 AC 107 ms
13,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	int n; cin >> n;
	two_sat sat(n);
	int m; cin >> m;
	rep(i,0,m){
		int x;
		string s;
		int y;
		cin >> x >> s >> y;
		x--; y--;
		if (s == "<==>"){
			sat.add_clause(x, 0, y, 1);
			sat.add_clause(y, 0, x, 1);
		}else{
			sat.add_clause(x, 1, y, 1);
			sat.add_clause(x, 0, y, 0);
			sat.add_clause(y, 0, x, 0);
			sat.add_clause(y, 1, x, 1);
		}
	}
	bool f = sat.satisfiable();
	if (!f){
		cout << "No\n";
		return 0;
	}

	vector<bool> g = sat.answer();
	int cnt = 0;
	rep(i,0,n){
		if (g[i]) cnt++;
	}
	if (cnt * 2 < n){
		rep(i,0,n){
			if (g[i] == 0){
				g[i] = 1;
			}else{
				g[i] = 0;
			}
		}
	}
	vector<int> ans;
	rep(i,0,n){
		if (g[i]){
			ans.push_back(i);
		}
	}
	
	cout << "Yes\n";
	int k = ans.size();
	cout << k << '\n';
	rep(i,0,k){
		cout << ans[i] + 1;
		if (i == k-1) cout << '\n';
		else cout << ' ';
	}
}

0