結果

問題 No.2536 同値性と充足可能性
ユーザー maksimmaksim
提出日時 2023-11-10 21:33:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,028 bytes
コンパイル時間 1,772 ms
コンパイル使用メモリ 172,584 KB
実行使用メモリ 25,580 KB
最終ジャッジ日時 2023-11-10 21:33:39
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
16,960 KB
testcase_02 WA -
testcase_03 AC 7 ms
16,960 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 7 ms
16,960 KB
testcase_20 AC 10 ms
17,336 KB
testcase_21 AC 10 ms
17,472 KB
testcase_22 AC 11 ms
17,472 KB
testcase_23 AC 46 ms
22,336 KB
testcase_24 AC 43 ms
22,080 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void dfs(long long int)':
main.cpp:10:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   10 |     for(auto [v,w]:a[x])
      |              ^

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int maxn=5e5+5;
vector<pair<int,int> > a[maxn];bool used[maxn];int col[maxn];
void dfs(int x)
{
    used[x]=true;
    for(auto [v,w]:a[x])
    {
        if(used[v])
        {
            if((col[v]^col[x])!=w) {puts("No");exit(0);}
        }
        else
        {
            col[v]=col[x]^w;
            dfs(v);
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;cin>>n>>m;
    for(int i=0;i<m;++i)
    {
        int x;cin>>x;string s;cin>>s;int y;cin>>y;--x;--y;
        if(s==("<==>")) {a[x].push_back({y,0});a[y].push_back({x,0});}
        else {a[x].push_back({y,1});a[y].push_back({x,1});}
    }
    for(int i=0;i<n;++i) if(!used[i]) dfs(i);
    int s=accumulate(col,col+n,0LL);
    if(2*s>=n){cout<<"Yes"<<'\n';cout<<s<<'\n';for(int i=0;i<n;++i) {if(col[i]) cout<<i+1<<' ';}}
    else {cout<<"Yes"<<'\n';cout<<n-s<<'\n';for(int i=0;i<n;++i) {if(!col[i]) cout<<i+1<<' ';}}
    return 0;
}
0