結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2026-07-14 02:22:48 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 251 ms / 5,000 ms |
| + 37µs | |
| コード長 | 1,181 bytes |
| 記録 | |
| コンパイル時間 | 2,406 ms |
| コンパイル使用メモリ | 342,880 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-14 02:23:10 |
| 合計ジャッジ時間 | 5,599 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
using u128=__int128_t;
using ll=long long;
V<int> G[20020];
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
random_device rd;
mt19937_64 rnd(rd());
int n,m;
cin>>n>>m;
rep(i,m){
int a,b;
cin>>a>>b;
a--,b--;
G[a].push_back(b);
G[b].push_back(a);
}
rep(_,200){
uniform_int_distribution<int> ud(0,4);
V<int> color(n);
rep(i,n) color[i]=ud(rnd);
VV<bool> dp(1<<5,V<bool>(n));
dp[1<<color[0]][0]=1;
for(int s=1;s<(1<<5)-1;s++){
rep(v,n){
if(dp[s][v]==0) continue;
for(auto nv:G[v]){
if(s>>color[nv]&1) continue;
dp[s|(1<<color[nv])][nv]=1;
}
}
}
rep(i,n){
if(dp[(1<<5)-1][i]){
for(auto nv:G[i]){
if(nv==0){
cout<<"YES\n";
return 0;
}
}
}
}
}
cout<<"NO\n";
return 0;
}
umezo