結果

問題 No.408 五輪ピック
ユーザー kotamanegikotamanegi
提出日時 2016-08-05 23:17:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,487 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 94,136 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 16:59:53
合計ジャッジ時間 2,138 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 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 1 ms
5,376 KB
testcase_05 AC 20 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 22 ms
5,376 KB
testcase_08 AC 18 ms
5,376 KB
testcase_09 AC 19 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 24 ms
5,376 KB
testcase_13 AC 23 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 21 ms
5,376 KB
testcase_16 AC 25 ms
5,376 KB
testcase_17 AC 27 ms
5,376 KB
testcase_18 AC 28 ms
5,376 KB
testcase_19 AC 29 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 14 ms
5,376 KB
testcase_23 AC 29 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 21 ms
5,376 KB
testcase_26 AC 31 ms
5,376 KB
testcase_27 AC 21 ms
5,376 KB
testcase_28 AC 16 ms
5,376 KB
testcase_29 AC 17 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 >= 3) {//5を超えた
			cout << "NO" << endl;
			return 0;
		}
		for (int i = 0;i < path[now_here].size();++i) {
			if (path[now_here][i] != before_come&&path[now_here][i] != 1) {
				if (have_come[score + 1][path[now_here][i]] == false) {
					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));
				}
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}
0