結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 24 ms
5,376 KB
testcase_06 AC 16 ms
5,504 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 AC 16 ms
5,376 KB
testcase_11 AC 15 ms
5,376 KB
testcase_12 AC 26 ms
5,504 KB
testcase_13 AC 24 ms
5,632 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 22 ms
5,760 KB
testcase_16 AC 24 ms
5,376 KB
testcase_17 AC 27 ms
5,504 KB
testcase_18 AC 28 ms
5,504 KB
testcase_19 AC 30 ms
5,632 KB
testcase_20 AC 8 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 14 ms
5,376 KB
testcase_23 AC 34 ms
6,272 KB
testcase_24 AC 24 ms
6,016 KB
testcase_25 AC 23 ms
5,760 KB
testcase_26 AC 32 ms
5,888 KB
testcase_27 AC 23 ms
5,888 KB
testcase_28 AC 18 ms
5,376 KB
testcase_29 AC 19 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 2 ms
5,376 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