結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
tossy
|
| 提出日時 | 2016-08-05 23:04:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,125 bytes |
| コンパイル時間 | 821 ms |
| コンパイル使用メモリ | 92,252 KB |
| 実行使用メモリ | 11,300 KB |
| 最終ジャッジ日時 | 2024-11-07 00:50:51 |
| 合計ジャッジ時間 | 8,033 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 WA * 3 TLE * 1 -- * 6 |
ソースコード
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second
#define INF 2147483600
#define N 20000
vector<int> g[N];
bool visited[N];
int from;
bool dfs(int f, int d){
if(d==0){ from=f; fill(visited, visited+N, false); }
if(d==4){
rep(i,g[f].size()) if(g[f][i]==from) return true;
return false;
}
visited[f]=true;
rep(i,g[f].size()) if(!visited[g[f][i]] && dfs(g[f][i], d+1)) return true;
visited[f]=false;
return false;
}
int main(){
int n,m;
cin>>n>>m;
rep(i,m){
int a,b;
scanf("%d %d", &a, &b);
a--;b--;
g[a].pb(b);
g[b].pb(a);
}
if(dfs(1,0)){
cout<<"YES"<<endl;
return 0;
}
cout<<"NO"<<endl;
return 0;
}
tossy