結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
femto
|
| 提出日時 | 2016-08-05 23:10:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 996 bytes |
| コンパイル時間 | 1,016 ms |
| コンパイル使用メモリ | 83,856 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 01:10:56 |
| 合計ジャッジ時間 | 2,190 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 WA * 4 |
ソースコード
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
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];
int group[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);
}
group[1] = 0;
int g = 1;
vector<P> one;
for(int c : G[1]) {
one.push_back(P(c, g));
group[c] = g;
g++;
}
vector<P> two;
for(P p : one) {
for(int c : G[p.first]) {
if(c == 1 || group[c] != 0) continue;
group[c] = p.second;
two.push_back(P(c, p.second));
}
}
for(P p : two) {
for(int c : G[p.first]) {
if(group[c] != 0 && group[c] != p.second) {
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
}
femto