結果
問題 |
No.2780 The Bottle Imp
|
ユーザー |
|
提出日時 | 2024-06-07 21:59:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 527 bytes |
コンパイル時間 | 3,246 ms |
コンパイル使用メモリ | 250,964 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 13:46:20 |
合計ジャッジ時間 | 5,837 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 WA * 5 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/dsu> using namespace std; int main() { int N; cin >> N; vector<int> d(N); atcoder::dsu uf(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]); } } bool ok1 = true, ok2 = true; for (int i = 1; i < N; i++) { if (d[i] == 0) ok1 = false; if (!uf.same(0, i)) ok2 = false; } if (ok1 && ok2) cout << "Yes\n"; else cout << "No\n"; }