結果

問題 No.408 五輪ピック
ユーザー togari_takamoto
提出日時 2016-08-05 23:31:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 776 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 173,008 KB
実行使用メモリ 814,636 KB
最終ジャッジ日時 2024-11-07 04:09:08
合計ジャッジ時間 3,622 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 MLE * 1 -- * 26
権限があれば一括ダウンロードができます

ソースコード

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({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({d + 1, e, cur});
		}
	}

	cout << "NO" << endl;

	return 0;
}
0