結果

問題 No.408 五輪ピック
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-08-08 00:06:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 1,073 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 172,804 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-25 00:38:37
合計ジャッジ時間 2,969 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,648 KB
testcase_01 AC 7 ms
11,648 KB
testcase_02 AC 6 ms
11,648 KB
testcase_03 AC 7 ms
11,520 KB
testcase_04 AC 7 ms
11,648 KB
testcase_05 AC 18 ms
12,672 KB
testcase_06 AC 14 ms
12,160 KB
testcase_07 AC 17 ms
12,160 KB
testcase_08 AC 15 ms
12,288 KB
testcase_09 AC 14 ms
12,160 KB
testcase_10 AC 14 ms
12,160 KB
testcase_11 AC 13 ms
12,032 KB
testcase_12 AC 19 ms
12,288 KB
testcase_13 AC 17 ms
12,416 KB
testcase_14 AC 9 ms
11,520 KB
testcase_15 AC 23 ms
13,952 KB
testcase_16 AC 17 ms
12,416 KB
testcase_17 AC 17 ms
12,416 KB
testcase_18 AC 18 ms
12,416 KB
testcase_19 AC 19 ms
12,544 KB
testcase_20 AC 11 ms
12,032 KB
testcase_21 AC 9 ms
11,648 KB
testcase_22 AC 14 ms
12,160 KB
testcase_23 AC 35 ms
16,256 KB
testcase_24 AC 24 ms
15,360 KB
testcase_25 AC 24 ms
14,336 KB
testcase_26 AC 23 ms
12,416 KB
testcase_27 AC 25 ms
14,336 KB
testcase_28 AC 18 ms
12,800 KB
testcase_29 AC 16 ms
12,672 KB
testcase_30 AC 7 ms
11,520 KB
testcase_31 AC 7 ms
11,648 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'std::string solve()':
main.cpp:30:25: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
   30 |                         if (a != b) return "YES";
      |                         ^~
main.cpp:26:29: note: 'a' was declared here
   26 |                         int a;
      |                             ^
main.cpp:30:25: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
   30 |                         if (a != b) return "YES";
      |                         ^~
main.cpp:28:29: note: 'b' was declared here
   28 |                         int b;
      |                             ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)


int N, M;
vector<int> E[101010];
//-----------------------------------------------------------------
unordered_set<int> C[101010];
string solve() {
	for (int i : E[0]) for (int j : E[i]) {
		if (j == 0) continue;
		C[j].insert(i);
	}

	rep(i, 0, N) for (int j : E[i]) {
		if (j < i) continue;
		if (i == 0 || j == 0) continue;

		int num_i = C[i].size();
		if (C[i].count(j)) num_i--;
		int num_j = C[j].size();
		if (C[j].count(i)) num_j--;

		if (num_i == 1 && num_j == 1) {
			int a;
			for (int k : C[i]) if (k != i && k != j) a = k;
			int b;
			for (int k : C[j]) if (k != i && k != j) b = k;
			if (a != b) return "YES";
		}

		if (1 <= num_i && 1 <= num_j) {
			int m = max(num_i, num_j);
			if (2 <= m) return "YES";
		}
	}

	return "NO";
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int A, B;
		scanf("%d %d", &A, &B);
		A--; B--;

		E[A].push_back(B);
		E[B].push_back(A);
	}
	cout << solve() << endl;
}
0