結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
kapo
|
| 提出日時 | 2016-08-09 13:43:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,802 bytes |
| コンパイル時間 | 1,102 ms |
| コンパイル使用メモリ | 88,576 KB |
| 実行使用メモリ | 7,680 KB |
| 最終ジャッジ日時 | 2024-11-07 08:11:14 |
| 合計ジャッジ時間 | 2,414 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
43 | scanf("%d %d", &V1[i], &V2[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
int N, M;
int V1[50001];
int V2[50001];
Vi A[50001];
Vi B[50001];
int main()
{
cin >> N >> M;
rep(i,0,M) {
scanf("%d %d", &V1[i], &V2[i]);
V1[i]--; V2[i]--;
A[V2[i]].pb(V1[i]);
A[V1[i]].pb(V2[i]);
}
for (auto a: A[0]) {
for (auto b: A[a]) {
if (b) B[b].pb(a);
}
}
rep(i, 0, M) {
int l = V1[i];
int r = V2[i];
if (B[l].size() && B[r].size()) {
//printf("l=%d r=%d len(B[l])=%d len(B[r])=%d\n",l,r,len(B[l]),len(B[r]));
if (B[l].size() == 1 && B[r].size() == 1) {
if (B[l][0] != B[r][0] && B[l][0] != r && B[r][0] != l) {
cout << "YES" << endl;
return 0;
}
}
else if (B[l].size() >= 1 && B[r].size() >= 1 && max(B[l].size(), B[r].size()) >= 2) {
if (B[l].size() >= 2) {
auto it = find(all(B[l]), r);
if (it != B[l].end()) continue;
}
if (B[r].size() >= 2) {
auto it = find(all(B[r]), l);
if (it != B[r].end()) continue;
}
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
return 0;
}
kapo