結果
| 問題 |
No.2536 同値性と充足可能性
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2023-11-10 22:07:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,624 bytes |
| コンパイル時間 | 1,279 ms |
| コンパイル使用メモリ | 124,196 KB |
| 最終ジャッジ日時 | 2025-02-17 20:51:51 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 23 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
string EQ = "<==>";
string NEQ = "<=/=>";
struct edge{
int to, c;
edge(int to, int c): to(to), c(c) {}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n, m; cin >> n >> m;
vector<vector<edge>> g(n);
for(int i = 0; i < m; i++){
int a, b; string s; cin >> a >> s >> b; a--; b--;
if(s == EQ){
g[a].push_back(edge(b, 0));
g[b].push_back(edge(a, 0));
}else{
g[a].push_back(edge(b, 1));
g[b].push_back(edge(a, 1));
}
}
vector<int> col(n, -1);
function<bool(int, int)> dfs = [&](int v, int c){
col[v] = c;
for(edge e: g[v]){
if(col[e.to] == -1){
if(!dfs(e.to, c^e.c)) return false;
}else{
if((c^e.c) != col[e.to]) return false;
}
}
return true;
};
for(int i = 0; i < n; i++) {
if(col[i] == -1){
if(!dfs(i, 0)) {
cout << "No" << endl;
return 0;
}
}
}
vector<vector<int>> v(2);
for(int i = 0; i < n; i++) v[col[i]].push_back(i);
for(int p = 0; p < 2; p++){
if(v[p].size()*2 >= n){
cout << "Yes" << endl;
cout << v[p].size() << endl;
for(int x: v[p]) cout << x+1 << ' ';
cout << endl;
return 0;
}
}
}
milanis48663220