結果
問題 |
No.408 五輪ピック
|
ユーザー |
![]() |
提出日時 | 2016-08-06 09:36:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,204 bytes |
コンパイル時間 | 929 ms |
コンパイル使用メモリ | 93,320 KB |
実行使用メモリ | 11,428 KB |
最終ジャッジ日時 | 2024-11-07 02:49:45 |
合計ジャッジ時間 | 8,558 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 3 TLE * 1 -- * 4 |
ソースコード
#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]; bool memo[4][N]; bool dfs(int f, int d){ if(d>0 && !memo[d-1][f]) return false; memo[d][f]=false; if(d==4){ rep(i,g[f].size()) if(g[f][i]==1) 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); } fill(visited, visited+N, false); fill(memo[0], memo[4], true); if(dfs(0,0)){ cout<<"YES"<<endl; return 0; } cout<<"NO"<<endl; return 0; }