結果

問題 No.408 五輪ピック
ユーザー kotamanegikotamanegi
提出日時 2016-08-06 00:08:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 1,712 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 94,068 KB
実行使用メモリ 6,380 KB
最終ジャッジ日時 2023-08-06 21:00:35
合計ジャッジ時間 2,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,828 KB
testcase_01 AC 3 ms
4,816 KB
testcase_02 AC 3 ms
4,744 KB
testcase_03 AC 3 ms
4,776 KB
testcase_04 AC 3 ms
4,736 KB
testcase_05 AC 23 ms
5,340 KB
testcase_06 AC 17 ms
5,592 KB
testcase_07 AC 24 ms
5,608 KB
testcase_08 AC 20 ms
5,248 KB
testcase_09 AC 21 ms
5,316 KB
testcase_10 AC 16 ms
5,392 KB
testcase_11 AC 16 ms
5,232 KB
testcase_12 AC 27 ms
5,716 KB
testcase_13 AC 23 ms
5,524 KB
testcase_14 AC 8 ms
4,944 KB
testcase_15 AC 23 ms
5,560 KB
testcase_16 AC 26 ms
5,424 KB
testcase_17 AC 28 ms
5,516 KB
testcase_18 AC 29 ms
5,580 KB
testcase_19 AC 31 ms
5,576 KB
testcase_20 AC 10 ms
5,160 KB
testcase_21 AC 7 ms
4,952 KB
testcase_22 AC 15 ms
5,352 KB
testcase_23 AC 37 ms
6,380 KB
testcase_24 AC 27 ms
6,136 KB
testcase_25 AC 23 ms
5,800 KB
testcase_26 AC 34 ms
5,724 KB
testcase_27 AC 23 ms
5,764 KB
testcase_28 AC 19 ms
5,452 KB
testcase_29 AC 19 ms
5,332 KB
testcase_30 AC 3 ms
5,068 KB
testcase_31 AC 3 ms
4,772 KB
権限があれば一括ダウンロードができます

ソースコード

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) {
				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) {
						if (copy_can_i.size() != 0 && copy_can_q.size() != 0) {
							cout << "YES" << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}
0