結果

問題 No.408 五輪ピック
ユーザー kotamanegikotamanegi
提出日時 2016-08-06 00:04:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,806 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 93,640 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-24 20:04:15
合計ジャッジ時間 2,440 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 23 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 24 ms
5,632 KB
testcase_08 AC 19 ms
5,376 KB
testcase_09 AC 21 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 15 ms
5,376 KB
testcase_12 AC 25 ms
5,504 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 24 ms
5,760 KB
testcase_16 AC 25 ms
5,504 KB
testcase_17 AC 28 ms
5,376 KB
testcase_18 AC 28 ms
5,632 KB
testcase_19 AC 30 ms
5,760 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 36 ms
6,528 KB
testcase_24 WA -
testcase_25 AC 26 ms
5,888 KB
testcase_26 AC 33 ms
5,888 KB
testcase_27 AC 26 ms
5,760 KB
testcase_28 AC 54 ms
5,376 KB
testcase_29 AC 53 ms
5,504 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];
vector<int> can_come_from[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);
	}
	for (int i = 0;i < path[1].size();++i) {
		for (int q = 0;q < path[path[1][i]].size();++q) {
			if (path[path[1][i]][q] != 1) {
				for (int j = 0;j < can_come_from[path[path[1][i]][q]].size();++j) {
					if (path[1][i] == can_come_from[path[path[1][i]][q]][j]) {
						goto fail;
					}
				}
				can_come_from[path[path[1][i]][q]].push_back(path[1][i]);
			}
		fail:;
		}
	}
	for (int i = 2;i <= n;++i) {
		if (can_come_from[i].size() != 0) {
			for (int q = 0;q < path[i].size();++q) {
				if (can_come_from[path[i][q]].size() != 0) {
					set<int> copy_can_i,copy_can_q;
					for (int j = 0;j < can_come_from[i].size();++j) {
						if (can_come_from[i][j] != path[i][q]) {
							copy_can_i.insert(can_come_from[i][j]);
						}
					}
					for (int j = 0;j < can_come_from[path[i][q]].size();++j) {
						if (can_come_from[path[i][q]][j] != i) {
							copy_can_q.insert(can_come_from[path[i][q]][j]);
						}
					}
					if (copy_can_i.size() > 1||copy_can_q.size() > 1||copy_can_i != copy_can_q) {
						cout << "YES" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}
0