結果

問題 No.2780 The Bottle Imp
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-06-08 13:28:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,190 bytes
コンパイル時間 2,637 ms
コンパイル使用メモリ 217,036 KB
実行使用メモリ 31,376 KB
最終ジャッジ日時 2024-06-08 13:28:41
合計ジャッジ時間 4,698 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 24 ms
9,256 KB
testcase_08 AC 28 ms
9,264 KB
testcase_09 AC 26 ms
9,260 KB
testcase_10 AC 25 ms
9,264 KB
testcase_11 AC 25 ms
9,260 KB
testcase_12 AC 42 ms
14,628 KB
testcase_13 AC 44 ms
14,616 KB
testcase_14 AC 18 ms
6,936 KB
testcase_15 AC 17 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 16 ms
6,940 KB
testcase_19 AC 17 ms
6,932 KB
testcase_20 AC 16 ms
7,064 KB
testcase_21 WA -
testcase_22 AC 11 ms
5,696 KB
testcase_23 AC 16 ms
6,712 KB
testcase_24 AC 22 ms
8,396 KB
testcase_25 AC 35 ms
11,512 KB
testcase_26 AC 20 ms
8,204 KB
testcase_27 AC 17 ms
7,384 KB
testcase_28 AC 17 ms
7,376 KB
testcase_29 AC 20 ms
10,388 KB
testcase_30 AC 16 ms
8,084 KB
testcase_31 AC 29 ms
11,300 KB
testcase_32 AC 11 ms
5,376 KB
testcase_33 AC 47 ms
27,664 KB
testcase_34 AC 53 ms
31,376 KB
testcase_35 AC 9 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 9 ms
5,376 KB
testcase_39 AC 30 ms
14,840 KB
testcase_40 AC 30 ms
14,840 KB
testcase_41 AC 29 ms
14,836 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/scc>
using namespace std;
using namespace atcoder;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    scc_graph scc(n);
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        for (int j = 0; j < m; j++) {
            int a;
            cin >> a;
            a--;
            g[i].push_back(a);
            scc.add_edge(i, a);
        }
    }
    auto sccs = scc.scc();
    vector<int> scc_index(n);
    for (int i = 0; i < sccs.size(); i++) {
        for (auto v : sccs[i]) {
            scc_index[v] = i;
        }
    }
    int l = sccs.size();
    vector<bool> ok(l - 1);
    for (int u = 0; u < n; u++) {
        for (int v : g[u]) {
            if (scc_index[u] == scc_index[v]) {
                continue;
            }
            if (scc_index[v] == scc_index[u] + 1) {
                ok[scc_index[u]] = true;
            }
        }
    }
    for (int i = 0; i < l - 1; i++) {
        if (!ok[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
0