結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2016-08-06 01:52:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,405 ms / 5,000 ms |
| コード長 | 1,780 bytes |
| コンパイル時間 | 968 ms |
| コンパイル使用メモリ | 83,252 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2024-11-07 01:58:33 |
| 合計ジャッジ時間 | 10,274 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
vector<int> v[20005];
int A[50005], B[50005];
int color[20005];
int dp[(1<<4)][20005];
int main(){
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
rep(i,M){
cin >> A[i] >> B[i];
v[A[i]].push_back(B[i]);
v[B[i]].push_back(A[i]);
}
bool ret = false;
rep(t,200){
rep(i,N+1) color[i] = rand()%4;
//REP(i,1,N+1) cout << color[i] << " "; cout << endl;
rep(i,(1<<4)) rep(j,20005) dp[i][j] = 0;
rep(i,v[1].size()){
dp[(1<<(color[v[1][i]]))][v[1][i]] = 1;
//cout << "init:" << color[v[1][i]] << " " << v[1][i] << endl;
}
rep(i,(1<<4)){
rep(j,N+1){
if(dp[i][j] == 1){
rep(k,v[j].size()){
if(v[j][k] == 1) continue;
//cout << "cand:" << j << "->" << v[j][k] << " " << i << endl;
if(((i>>color[v[j][k]])&1) == 0){
//cout << "add:" << (i | (1<<(color[v[j][k]]))) << " " << v[j][k] << endl;
dp[i | (1<<(color[v[j][k]]))][v[j][k]] = 1;
}
}
}
}
}
rep(i,N+1){
if(dp[(1<<4)-1][i] == 1){
//cout << i << endl;
rep(j,v[i].size()) if(v[i][j] == 1) ret = true;
}
}
}
if(ret) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
どらら