結果

問題 No.2780 The Bottle Imp
ユーザー hiro1729hiro1729
提出日時 2024-06-07 22:14:32
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 744 bytes
コンパイル時間 5,675 ms
コンパイル使用メモリ 289,768 KB
実行使用メモリ 25,052 KB
最終ジャッジ日時 2024-06-08 10:31:24
合計ジャッジ時間 8,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 42 ms
7,124 KB
testcase_08 AC 40 ms
7,252 KB
testcase_09 AC 41 ms
7,380 KB
testcase_10 AC 43 ms
7,380 KB
testcase_11 AC 42 ms
7,252 KB
testcase_12 AC 69 ms
11,104 KB
testcase_13 AC 68 ms
10,972 KB
testcase_14 AC 33 ms
6,040 KB
testcase_15 AC 32 ms
5,912 KB
testcase_16 AC 33 ms
5,912 KB
testcase_17 AC 33 ms
5,908 KB
testcase_18 AC 33 ms
6,040 KB
testcase_19 AC 33 ms
6,040 KB
testcase_20 AC 34 ms
5,916 KB
testcase_21 AC 33 ms
5,912 KB
testcase_22 AC 18 ms
5,376 KB
testcase_23 AC 28 ms
5,816 KB
testcase_24 AC 35 ms
6,680 KB
testcase_25 AC 55 ms
8,952 KB
testcase_26 AC 37 ms
6,596 KB
testcase_27 AC 28 ms
5,448 KB
testcase_28 AC 28 ms
5,388 KB
testcase_29 WA -
testcase_30 AC 27 ms
6,540 KB
testcase_31 AC 49 ms
7,184 KB
testcase_32 AC 23 ms
5,376 KB
testcase_33 AC 66 ms
21,596 KB
testcase_34 AC 75 ms
25,052 KB
testcase_35 AC 16 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 17 ms
5,376 KB
testcase_39 AC 50 ms
11,232 KB
testcase_40 AC 50 ms
11,100 KB
testcase_41 WA -
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/dsu>
#include <atcoder/scc>
using namespace std;

int main() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Yes\n";
		return 0;
	}
	vector<int> d(N);
	atcoder::dsu uf(N);
	atcoder::scc_graph scc(N);
	for (int i = 0; i < N; i++) {
		int M; cin >> M;
		vector<int> A(M);
		for (int j = 0; j < M; j++) cin >> A[j];
		for (int j = 0; j < M; j++) {
			A[j]--;
			d[A[j]]++;
			uf.merge(i, A[j]);
			scc.add_edge(i, A[j]);
		}
	}
	bool ok1 = true, ok2 = true, ok3 = false;
	vector<int> s = scc.scc()[0];
	for (int i: s) if (i == 0) ok3 = true;
	for (int i = 1; i < N; i++) {
		if (d[i] == 0) ok1 = false;
		if (!uf.same(0, i)) ok2 = false;
	}
	if (ok1 && ok2 && ok3) cout << "Yes\n";
	else cout << "No\n";
}
0