結果

問題 No.2536 同値性と充足可能性
ユーザー k1suxuk1suxu
提出日時 2023-11-10 23:51:18
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,092 bytes
コンパイル時間 7,032 ms
コンパイル使用メモリ 314,348 KB
実行使用メモリ 17,564 KB
最終ジャッジ日時 2023-11-10 23:51:31
合計ジャッジ時間 11,869 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 5 ms
6,676 KB
testcase_21 AC 6 ms
6,676 KB
testcase_22 AC 6 ms
6,676 KB
testcase_23 AC 44 ms
14,992 KB
testcase_24 AC 43 ms
14,096 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

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

#define rep(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define all(x) x.begin(),x.end()
//#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vvvvi vector<vvvi>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const ll INF = numeric_limits<long long>::max() / 2;
const ld pi = 3.1415926535897932384626433832795028;
const ll mod = 998244353;
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};

#include"atcoder/all"

void solve() {
    int n, m;
    cin >> n >> m;

    atcoder::two_sat sat(n);
    FOR(m) {
        int u, v;
        string s;
        cin >> u >> s >> v;
        --u;
        --v;

        if(s == "<==>") {
            sat.add_clause(u, false, v, true);
            sat.add_clause(v, false, u, true);
        }else {
            sat.add_clause(u, true, v, true);
            sat.add_clause(v, true, u, true);
            sat.add_clause(u, false, v, false);
            sat.add_clause(v, false, u, false);
        }
    }

    bool satisfy = sat.satisfiable();
    vector<bool> ans = sat.answer();

    if(!satisfy) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;

    int sz = (int)count(all(ans), true);

    if(2*sz >= n) {
        cout << sz << endl;
        FOR(n) if(ans[i]) cout << i+1 << " "; cout << "\n";
    }else {
        cout << n-sz << endl;
        FOR(n) if(!ans[i]) cout << i+1 << " "; cout << "\n";
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}
0