結果

問題 No.2536 同値性と充足可能性
ユーザー cho435cho435
提出日時 2023-11-10 23:25:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,201 bytes
コンパイル時間 4,840 ms
コンパイル使用メモリ 274,212 KB
実行使用メモリ 10,728 KB
最終ジャッジ日時 2023-11-10 23:25:59
合計ジャッジ時間 9,977 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,676 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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 88 ms
6,676 KB
testcase_24 AC 84 ms
6,676 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

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";
		for(int x:ans) cout<<x+1<<"\n";
	}else{
		cout<<"No\n";
	}
}
0