結果

問題 No.408 五輪ピック
ユーザー 👑 kmjpkmjp
提出日時 2016-08-05 22:39:32
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,216 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 162,536 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-04-24 15:51:21
合計ジャッジ時間 8,684 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,064 KB
testcase_01 AC 4 ms
8,064 KB
testcase_02 AC 4 ms
8,064 KB
testcase_03 AC 6 ms
8,128 KB
testcase_04 AC 4 ms
8,192 KB
testcase_05 AC 13 ms
8,848 KB
testcase_06 AC 11 ms
8,832 KB
testcase_07 AC 16 ms
8,960 KB
testcase_08 AC 12 ms
8,576 KB
testcase_09 AC 13 ms
8,752 KB
testcase_10 AC 13 ms
8,576 KB
testcase_11 AC 12 ms
8,576 KB
testcase_12 AC 17 ms
8,960 KB
testcase_13 AC 13 ms
8,960 KB
testcase_14 AC 7 ms
8,320 KB
testcase_15 AC 13 ms
8,576 KB
testcase_16 AC 14 ms
8,812 KB
testcase_17 AC 16 ms
8,960 KB
testcase_18 AC 17 ms
8,932 KB
testcase_19 AC 19 ms
9,212 KB
testcase_20 AC 8 ms
8,576 KB
testcase_21 AC 6 ms
8,264 KB
testcase_22 AC 11 ms
8,704 KB
testcase_23 AC 21 ms
9,216 KB
testcase_24 AC 15 ms
9,088 KB
testcase_25 AC 16 ms
8,832 KB
testcase_26 AC 21 ms
9,088 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0