結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
togari_takamoto
|
| 提出日時 | 2016-08-05 23:32:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 810 bytes |
| コンパイル時間 | 1,874 ms |
| コンパイル使用メモリ | 172,284 KB |
| 実行使用メモリ | 817,960 KB |
| 最終ジャッジ日時 | 2024-11-07 04:15:49 |
| 合計ジャッジ時間 | 4,852 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 MLE * 1 -- * 26 |
ソースコード
#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;
}
togari_takamoto