結果

問題 No.408 五輪ピック
ユーザー togari_takamototogari_takamoto
提出日時 2016-08-05 23:32:07
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 810 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 172,508 KB
実行使用メモリ 817,324 KB
最終ジャッジ日時 2024-04-24 19:25:09
合計ジャッジ時間 3,563 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, m; cin >> n >> m;
	vvl g(n);
	vector<pair<ll, ll>> ab;
	REP(i, m) {
		ll a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<tuple<ll, ll, ll>> que;
	que.push(tuple<ll, ll, ll>(0, 0, -1));
	while (!que.empty()) {
		ll d, cur, prev;
		tie(d, cur, prev) = que.front(); que.pop();
		if (d > 5) break;
		for (auto e : g[cur]) if (prev != e) {
			if (d + 1 == 5 && e == 0) {
				cout << "YES" << endl;
				return 0;
			}
			que.push(tuple<ll, ll, ll>(d + 1, e, cur));
		}
	}

	cout << "NO" << endl;

	return 0;
}
0