結果

問題 No.1865 Make Cycle
ユーザー 👑 hitonanodehitonanode
提出日時 2023-05-10 07:11:27
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 207 ms / 3,000 ms
コード長 541 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 107,732 KB
実行使用メモリ 12,444 KB
最終ジャッジ日時 2024-05-04 22:06:18
合計ジャッジ時間 6,437 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
8,404 KB
testcase_01 AC 109 ms
7,372 KB
testcase_02 AC 175 ms
9,124 KB
testcase_03 AC 94 ms
8,328 KB
testcase_04 AC 143 ms
9,932 KB
testcase_05 AC 186 ms
9,584 KB
testcase_06 AC 162 ms
8,728 KB
testcase_07 AC 149 ms
8,232 KB
testcase_08 AC 171 ms
9,836 KB
testcase_09 AC 151 ms
9,692 KB
testcase_10 AC 190 ms
9,284 KB
testcase_11 AC 149 ms
9,428 KB
testcase_12 AC 153 ms
8,504 KB
testcase_13 AC 145 ms
8,420 KB
testcase_14 AC 111 ms
8,252 KB
testcase_15 AC 188 ms
9,084 KB
testcase_16 AC 178 ms
12,444 KB
testcase_17 AC 146 ms
7,968 KB
testcase_18 AC 206 ms
9,972 KB
testcase_19 AC 207 ms
11,172 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/scc>
#include <iostream>
using namespace std;

int A[100000];
int B[100000];

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    for (int q = 0; q < Q; ++q) cin >> A[q] >> B[q];

    int ng = 0, ok = Q + 1;
    while (ok - ng > 1) {
        const int c = (ok + ng) / 2;
        atcoder::scc_graph g(N + 1);
        for (int e = 0; e < c; ++e) g.add_edge(A[e], B[e]);
        (int(g.scc().size()) < N + 1 ? ok : ng) = c;
    }
    cout << (ok == Q + 1 ? -1 : ok) << '\n';
}
0