結果
問題 | No.408 五輪ピック |
ユーザー |
![]() |
提出日時 | 2016-08-05 22:39:32 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,216 bytes |
コンパイル時間 | 1,572 ms |
コンパイル使用メモリ | 163,272 KB |
実行使用メモリ | 15,524 KB |
最終ジャッジ日時 | 2024-11-07 00:27:26 |
合計ジャッジ時間 | 8,696 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 TLE * 1 -- * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,M; vector<int> E[202020]; int yes[202020]; vector<int> S; bitset<202020> B; void dfs() { int cur=S.back(); if(S.size()==5) { if(yes[cur]) { _P("YES\n"); exit(0); } return; } int i; FORR(e,E[cur]) { if(B[e]) continue; B[e]=1; S.push_back(e); dfs(); B[e]=0; S.pop_back(); } } void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M; FOR(i,M) { cin>>x>>y; E[x-1].push_back(y-1); E[y-1].push_back(x-1); if(x==1) yes[y-1]=1; if(y==1) yes[x-1]=1; } S.push_back(0); B.set(0); dfs(); _P("NO\n"); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }