結果
| 問題 | 
                            No.2536 同値性と充足可能性
                             | 
                    
| コンテスト | |
| ユーザー | 
                             shobonvip
                         | 
                    
| 提出日時 | 2023-11-10 21:35:59 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 121 ms / 2,000 ms | 
| コード長 | 1,882 bytes | 
| コンパイル時間 | 4,715 ms | 
| コンパイル使用メモリ | 255,932 KB | 
| 最終ジャッジ日時 | 2025-02-17 20:30:18 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 31 | 
ソースコード
#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 << ' ';
	}
}
            
            
            
        
            
shobonvip