結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
srup٩(๑`н´๑)۶
|
| 提出日時 | 2016-10-18 17:34:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,343 bytes |
| コンパイル時間 | 725 ms |
| コンパイル使用メモリ | 75,552 KB |
| 実行使用メモリ | 18,640 KB |
| 最終ジャッジ日時 | 2024-11-22 12:23:38 |
| 合計ジャッジ時間 | 91,408 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 4 TLE * 12 |
ソースコード
#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> 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));
}
/*
p
/ \
u2 v2
\ |
u1-v1
*/
for(auto d : hen){
int u1 = d.first, v1 = d.second;
// printf("u1 %d v1 %d\n", u1, v1);
for(auto u2 : G[u1]){
for(auto v2 : G[v1]){
// printf("u2 %d v2 %d\n", u2, v2);
if(u2 == v1) continue;
if(u1 == v2) continue;
if(u2 == v1) continue;
// printf("u2 %d v2 %d\n", u2, v2);
for (int p = 0; p < n; ++p){
if(p == u1 || p == u2 || p == v1 || p == v2) continue;
if(memo.count(make_pair(u2, p)) && memo.count(make_pair(v2, p))){
if(u1 == 0 || u2 == 0 || v1 == 0 || v2 == 0 || p == 0){
// printf("ok u1 %d v1 %d\n", u1, v1);
// printf("ok u2 %d v2 %d\n", u2, v2);
// printf("p %d\n", p);
printf("YES\n");
return 0;
}
}
}
}
}
}
printf("NO\n");
return 0;
}
srup٩(๑`н´๑)۶