結果

問題 No.408 五輪ピック
ユーザー kapokapo
提出日時 2016-08-09 12:38:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 1,052 ms
コンパイル使用メモリ 88,152 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-24 22:53:02
合計ジャッジ時間 2,510 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,888 KB
testcase_01 AC 3 ms
5,760 KB
testcase_02 AC 3 ms
5,760 KB
testcase_03 AC 4 ms
5,760 KB
testcase_04 AC 3 ms
5,760 KB
testcase_05 AC 14 ms
6,400 KB
testcase_06 AC 13 ms
6,400 KB
testcase_07 AC 15 ms
6,528 KB
testcase_08 AC 12 ms
6,272 KB
testcase_09 AC 13 ms
6,400 KB
testcase_10 AC 12 ms
6,272 KB
testcase_11 AC 12 ms
6,272 KB
testcase_12 AC 19 ms
6,656 KB
testcase_13 AC 15 ms
6,528 KB
testcase_14 AC 7 ms
6,144 KB
testcase_15 AC 14 ms
6,656 KB
testcase_16 AC 15 ms
6,400 KB
testcase_17 AC 16 ms
6,528 KB
testcase_18 AC 18 ms
6,656 KB
testcase_19 AC 21 ms
6,784 KB
testcase_20 AC 8 ms
6,144 KB
testcase_21 AC 6 ms
6,144 KB
testcase_22 AC 11 ms
6,400 KB
testcase_23 AC 25 ms
7,296 KB
testcase_24 WA -
testcase_25 AC 15 ms
6,912 KB
testcase_26 AC 23 ms
6,656 KB
testcase_27 AC 18 ms
6,656 KB
testcase_28 AC 12 ms
6,528 KB
testcase_29 AC 12 ms
6,400 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:42:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |                 scanf("%d %d", &a, &b);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
Vi A[50001];
Vi B[50001];

int main()
{
	cin >> N >> M;
	rep(i,0,M) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		A[a].pb(b);
		A[b].pb(a);
	}

	for (auto a: A[0]) {
		for (auto b: A[a]) {
			if (b) B[b].pb(a);
		}
	}

	rep(i, 0, N - 1) {
		if (B[i].size()) {
			rep(j, i+1, N) {
				if (B[j].size()) {
					//printf("i=%d, j=%d\n",i,j);
					auto it = find(all(A[j]), i);
					if (it != A[j].end()) {
						if (B[i].size() == 1 && B[j].size() == 1) {
							if (B[i][0] != B[j][0]) {
								cout << "YES" << endl;
								return 0;
							} 
						}
						else if (B[i].size() >= 1 && B[j].size() >= 1 && max(B[i].size(), B[j].size()) >= 2) {
							cout << "YES" << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}
0