結果

問題 No.408 五輪ピック
ユーザー femto
提出日時 2016-08-05 23:30:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,020 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 92,152 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-07 04:06:37
合計ジャッジ時間 2,677 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <set>
using namespace std;
template<typename T> void setmin(T& a, T& b) { a = min(a, b); }
template<typename T> void setmax(T& a, T& b) { a = max(a, b); }

typedef pair<int, int> P;

int N, M;

vector<int> G[20001];
vector<int> par[20001];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	set<int> two;
	for(int c : G[1]) {
		for(int cc : G[c]) {
			if(cc == 1) continue;
			par[cc].push_back(c);
			two.insert(cc);
		}
	}

	for(int i = 1; i <= N; i++) {
		sort(par[i].begin(), par[i].end());
	}

	for(int cc : two) {
		for(int ccc : G[cc]) {
			for(int p : par[cc]) {
				if(two.find(ccc) != two.end() && !binary_search(par[ccc].begin(), par[ccc].end(), p)) {
					cout << "YES" << endl;
					return 0;
				}
			}
		}
	}
	cout << "NO" << endl;
}
0