結果

問題 No.2536 同値性と充足可能性
ユーザー cho435cho435
提出日時 2023-11-10 21:58:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 1,243 bytes
コンパイル時間 5,483 ms
コンパイル使用メモリ 274,324 KB
実行使用メモリ 10,728 KB
最終ジャッジ日時 2023-11-10 21:58:48
合計ジャッジ時間 7,982 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 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 2 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 87 ms
6,676 KB
testcase_24 AC 86 ms
6,676 KB
testcase_25 AC 140 ms
10,620 KB
testcase_26 AC 140 ms
10,596 KB
testcase_27 AC 146 ms
10,728 KB
testcase_28 AC 136 ms
10,552 KB
testcase_29 AC 134 ms
10,484 KB
testcase_30 AC 133 ms
10,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<pair<int,int>>> g(n);
	atcoder::dsu uf(n);
	rep(i,m){
		int a,b;
		string s;
		cin>>a>>s>>b;
		a--; b--;
		g.at(a).push_back({b,(s=="<=/=>")});
		g.at(b).push_back({a,(s=="<=/=>")});
		uf.merge(a,b);
	}
	vector<int> ans;
	vector<int> cl(n,-1);
	rep(i,n){
		if(cl.at(i)!=-1) continue;
		vector<vector<int>> vv(2);
		cl.at(i)=0;
		queue<int> q;
		q.push(i);
		auto flg=[&](){
			while(!q.empty()){
				int x=q.front();
				q.pop();
				vv.at(cl.at(x)).push_back(x);
				for(auto[y,f]:g.at(x)){
					if(cl.at(y)==-1){
						cl.at(y)=cl.at(x)^f;
						q.push(y);
					}else{
						if(cl.at(y)!=(cl.at(x)^f)){
							return 1;
						}
					}
				}
			}	
			return 0;
		}();
		if(!flg){
			if(vv.at(0).size()<vv.at(1).size()) swap(vv.at(0),vv.at(1));
			copy(vv.at(0).begin(),vv.at(0).end(),back_inserter(ans));
		}
	}
	sort(ans.begin(),ans.end());
	if((int)ans.size()>=n/2){
		cout<<"Yes\n";
		cout<<ans.size()<<"\n";
		rep(i,ans.size()){
			cout<<ans.at(i)+1<<" \n"[i+1==(int)ans.size()];
		}
	}else{
		cout<<"No\n";
	}
}
0