結果

問題 No.1983 [Cherry 4th Tune C] 南の島のマーメイド
ユーザー V_MelvilleV_Melville
提出日時 2022-08-29 03:26:34
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 659 ms / 4,000 ms
コード長 1,264 bytes
コンパイル時間 8,639 ms
コンパイル使用メモリ 371,448 KB
実行使用メモリ 50,864 KB
最終ジャッジ日時 2024-04-23 21:22:50
合計ジャッジ時間 27,225 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 14 ms
5,376 KB
testcase_09 AC 20 ms
5,376 KB
testcase_10 AC 20 ms
5,376 KB
testcase_11 AC 25 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 400 ms
12,288 KB
testcase_14 AC 459 ms
16,428 KB
testcase_15 AC 462 ms
13,700 KB
testcase_16 AC 254 ms
10,624 KB
testcase_17 AC 451 ms
18,048 KB
testcase_18 AC 349 ms
13,824 KB
testcase_19 AC 409 ms
20,992 KB
testcase_20 AC 387 ms
13,184 KB
testcase_21 AC 412 ms
17,380 KB
testcase_22 AC 466 ms
23,040 KB
testcase_23 AC 653 ms
24,984 KB
testcase_24 AC 659 ms
24,888 KB
testcase_25 AC 658 ms
24,960 KB
testcase_26 AC 659 ms
24,840 KB
testcase_27 AC 655 ms
24,960 KB
testcase_28 AC 659 ms
24,832 KB
testcase_29 AC 657 ms
24,948 KB
testcase_30 AC 654 ms
24,832 KB
testcase_31 AC 647 ms
24,960 KB
testcase_32 AC 654 ms
24,924 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 394 ms
10,232 KB
testcase_35 AC 562 ms
50,864 KB
testcase_36 AC 537 ms
16,640 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 317 ms
5,376 KB
testcase_39 AC 571 ms
50,828 KB
testcase_40 AC 533 ms
17,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::min;
using std::vector;
using std::function;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    
    vector<vector<int>> to(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    vector<int> ord(n, n);
    vector<int> low(n, n);
    dsu t(n);
    int id = 0;
    function<void(int, int)> tarjan = [&](int v, int p) {
        ord[v] = low[v] = id++;
        for (int u : to[v]) {
            if (u == p) continue;
            if (ord[u] == n) {
                tarjan(u, v);
                low[v] = min(low[v], low[u]);
                if (ord[v] < low[u]) {
                    t.merge(v, u);
                }
            }
            else {
                low[v] = min(low[v], ord[u]);
            }
        }
    };
    rep(i, n) { 
        if (ord[i] == n) tarjan(i, n);
    }
    
    rep(qi, q) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        if (t.same(a, b)) puts("Yes");
        else puts("No");
    }
    
    return 0;
}
0