結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-09-15 21:39:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 5,000 ms |
| コード長 | 1,404 bytes |
| コンパイル時間 | 999 ms |
| コンパイル使用メモリ | 92,212 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2024-11-17 06:13:44 |
| 合計ジャッジ時間 | 2,777 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;
#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl
vector<int> e[20000];
set<int> s[20000];
int main(void) {
int i, n, m;
scanf("%d%d",&n,&m);
REP (i,m) {
int a, b;
scanf("%d%d",&a,&b);
a--; b--;
e[a].push_back(b);
e[b].push_back(a);
}
for (auto x: e[0]) for (auto y: e[x]) if (y != 0) {
s[y].insert(x);
}
bool ans = false;
REP (i,n) for (auto x: e[i]) if (x != 0) {
bool bi = s[i].count(x), bx = s[x].count(i);
if (bi) s[i].erase(x);
if (bx) s[x].erase(i);
int ni = s[i].size(), nx = s[x].size();
if (ni == 1 && nx == 1 && *s[i].begin() != *s[x].begin()) ans = true;
else if ((ni > 1 && nx > 0) || (ni > 0 && nx > 1)) ans = true;
if (bi) s[i].insert(x);
if (bx) s[x].insert(i);
}
if (ans)
puts("YES");
else
puts("NO");
return 0;
}
h_noson