結果
| 問題 |
No.2277 Honest or Dishonest ?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-21 21:37:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 473 bytes |
| コンパイル時間 | 1,014 ms |
| コンパイル使用メモリ | 79,744 KB |
| 実行使用メモリ | 14,336 KB |
| 最終ジャッジ日時 | 2024-11-08 06:24:46 |
| 合計ジャッジ時間 | 4,107 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
#include<iostream>
#include<atcoder/dsu>
using namespace std;
int N,M;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M;
atcoder::dsu uf(2*N);
for(;M--;)
{
int a,b,c;cin>>a>>b>>c;
a--,b--;
if(c==1)
{
uf.merge(a,N+b);
uf.merge(N+a,b);
}
else
{
uf.merge(a,b);
uf.merge(N+a,N+b);
}
}
int ans=1;
for(int i=0;i<N;i++)if(uf.same(i,N+i))ans=0;
for(int i=uf.groups().size()/2;i--;)ans=ans*2%998244353;
cout<<ans<<endl;
}