結果
| 問題 |
No.2780 The Bottle Imp
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-07 22:03:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 695 bytes |
| コンパイル時間 | 3,786 ms |
| コンパイル使用メモリ | 261,752 KB |
| 実行使用メモリ | 25,052 KB |
| 最終ジャッジ日時 | 2024-12-27 13:48:35 |
| 合計ジャッジ時間 | 6,711 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 36 WA * 4 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/dsu>
#include <atcoder/scc>
using namespace std;
int main() {
int N;
cin >> N;
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";
}