結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
srup٩(๑`н´๑)۶
|
| 提出日時 | 2016-10-18 18:13:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 5,000 ms |
| コード長 | 1,037 bytes |
| コンパイル時間 | 640 ms |
| コンパイル使用メモリ | 68,836 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-22 12:33:58 |
| 合計ジャッジ時間 | 2,597 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
int n, m;
vector<pair<int, int> > hen;
// set<pair<int, int> > memo;
vector<int> e[20010];// e[u2][u1] := 0 -> u1 -> u2
vector<int> G[20010];
int main(void){
cin >> n >> m;
rep(i, m){
int x, y; cin >> x >> y;
x--; y--;
G[x].push_back(y);
G[y].push_back(x);
hen.push_back(make_pair(x, y));
// memo.insert(make_pair(x, y));
// memo.insert(make_pair(y, x));
}
/*
0
/ \
u1 v1
\ |
u2-v2
*/
for(auto u1 : G[0]){
for(auto u2 : G[u1]){
if(u1 != u2 && u2 != 0){
e[u2].push_back(u1);
}
}
}
for(auto d : hen){
int u2 = d.first, v2 = d.second;
if(u2 == 0 || v2 == 0) continue;
for(auto u1 : e[u2]){
for(auto v1 : e[v2]){
if(u1 != v1 && u1 != v2 && v1 != u2 && u2 != v2){
printf("YES\n");
return 0;
}
}
}
}
printf("NO\n");
return 0;
}
srup٩(๑`н´๑)۶