結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
kotamanegi
|
| 提出日時 | 2016-08-05 23:12:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,504 bytes |
| 記録 | |
| コンパイル時間 | 944 ms |
| コンパイル使用メモリ | 94,020 KB |
| 実行使用メモリ | 817,592 KB |
| 最終ジャッジ日時 | 2024-11-07 01:12:16 |
| 合計ジャッジ時間 | 4,842 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 3 MLE * 1 -- * 4 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
vector<int> path[30000];
bool have_come[10][30000] = {};
int main() {
int n, m;
cin >> n >> m;
REP(i, m) {
int a, b;
cin >> a >> b;
path[a].push_back(b);
path[b].push_back(a);
}
queue<tuple<int,int,int>> hoge;
hoge.push(make_tuple(1,1,0));
have_come[0][1] = true;
while (hoge.empty() == false) {
int now_here = get<0>(hoge.front());
int before_come = get<1>(hoge.front());
int score = get<2>(hoge.front());
hoge.pop();
if (score >= 5) {//5を超えた
cout << "NO" << endl;
return 0;
}
for (int i = 0;i < path[now_here].size();++i) {
if (path[now_here][i] != before_come) {
if (have_come[4 - score][path[now_here][i]] == true) {
cout << "YES" << endl;
return 0;
}
have_come[score+1][path[now_here][i]] = true;
hoge.push(make_tuple(path[now_here][i], now_here, score + 1));
}
}
}
//そもそも道すらなかった場合
if (have_come[5][1] == true) {
cout << "YES" << endl;
return 0;
}
cout << "NO" << endl;
return 0;
}
kotamanegi