結果

問題 No.408 五輪ピック
ユーザー keikei
提出日時 2016-11-04 21:11:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 783 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 82,900 KB
実行使用メモリ 389,532 KB
最終ジャッジ日時 2024-05-03 22:10:27
合計ジャッジ時間 7,820 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#define INF 1<<30
using namespace std;
bool Ans = false;
int N, M;
void dfs(vector<vector<int>> v,int prev,int next,int n) {

	//cout << "next = " << next << " n = " << n << endl;

	if (n == N) { return ; }
	for (int i = 0; i < v[next].size();i++) {
		int f = v[next][i];
		if (f == 1 && n + 1 == N) {
			Ans = true;
		}
		if (f != 1 && f != prev) dfs(v,next, f, n + 1);
	}
	return ;
}

int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	cin >> N >> M;
	vector< vector<int>> v(N + 1);
	for (int i = 0; i < M;i++) {
		int a, b; cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(v,0, 1, 0);
	if (Ans) {
		cout << "YES";
	}
	else { cout << "NO"; }
	cout << endl;
	return 0;
}
0