結果
| 問題 |
No.2664 Prime Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-08 21:38:14 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 938 bytes |
| コンパイル時間 | 24,979 ms |
| コンパイル使用メモリ | 358,304 KB |
| 最終ジャッジ日時 | 2025-02-20 02:17:24 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 37 |
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
void IO(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
int main(){
IO();
ll n,m;
cin>>n>>m;
vector<vector<ll>> G(n);
for(ll i=0;i<m;i++){
ll a,b;
cin>>a>>b;
a--;
b--;
G[a].push_back(b);
G[b].push_back(a);
}
bool ok=true;
vector<ll> co(n,-1);
for(ll i=0;i<n;i++){
if(co[i]==-1){
co[i]=0;
queue<ll> que;
que.push(i);
while(que.size()){
ll q=que.front();
que.pop();
for(ll u:G[q]){
if(co[u]==-1){
co[u]=(co[q]+1)%2;
que.push(u);
}else if(co[u]==co[q]){
ok=false;
}
}
}
}
}
if(ok){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}