結果

問題 No.812 Change of Class
ユーザー granddaifukugranddaifuku
提出日時 2020-04-26 19:15:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,609 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 173,576 KB
実行使用メモリ 9,364 KB
最終ジャッジ日時 2023-08-11 05:19:34
合計ジャッジ時間 9,959 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
8,036 KB
testcase_01 AC 9 ms
4,380 KB
testcase_02 AC 32 ms
5,888 KB
testcase_03 AC 68 ms
8,816 KB
testcase_04 AC 60 ms
8,196 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,416 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 11 ms
6,892 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 19 ms
4,456 KB
testcase_36 AC 8 ms
4,384 KB
testcase_37 AC 47 ms
5,272 KB
testcase_38 AC 4 ms
4,948 KB
testcase_39 AC 47 ms
5,328 KB
testcase_40 AC 12 ms
4,384 KB
testcase_41 AC 4 ms
4,704 KB
testcase_42 AC 98 ms
7,164 KB
testcase_43 AC 20 ms
6,300 KB
testcase_44 AC 69 ms
6,228 KB
testcase_45 AC 8 ms
4,380 KB
testcase_46 AC 18 ms
6,292 KB
testcase_47 AC 68 ms
6,108 KB
testcase_48 AC 76 ms
6,840 KB
testcase_49 AC 19 ms
4,492 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 20 ms
4,676 KB
testcase_52 AC 39 ms
6,400 KB
testcase_53 AC 14 ms
4,380 KB
testcase_54 AC 11 ms
4,380 KB
testcase_55 AC 37 ms
7,396 KB
testcase_56 AC 44 ms
8,236 KB
testcase_57 AC 47 ms
8,504 KB
testcase_58 AC 26 ms
5,920 KB
testcase_59 AC 53 ms
9,364 KB
testcase_60 AC 1 ms
4,384 KB
testcase_61 AC 2 ms
4,384 KB
testcase_62 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int check(int x) {
    int cnt = 0;
    while (x > 0) {
        x /= 2;
        cnt++;
    }

    return cnt;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m, q;
    cin >> n >> m;
    vector<int> g[n];
    rep (i, m) {
        int s, t;
        cin >> s >> t;
        g[s - 1].push_back(t - 1);
        g[t - 1].push_back(s - 1);
    }
    cin >> q;
    rep (i, q) {
        int a;
        cin >> a;
        a--;
        if (g[a].size() == 0) {
            cout << 0 << " " << 0 << endl;
            continue;
        }
        int cnt = 0;
        int day = 0;
        vector<int> checked(n, Inf);
        queue<int> q;
        rep (j, g[a].size()) {
            q.push(g[a][j]);
            checked[g[a][j]] = 0;
            cnt++;
        }
        checked[a] = 0;
        while (!q.empty()) {
            int next = q.front();
            q.pop();
            rep (j, g[next].size()) {
                if (checked[g[next][j]] < checked[next] + 1) continue;
                checked[g[next][j]] = checked[next] + 1;
                q.push(g[next][j]);
                cnt++;
            }
            int tmp = check(checked[next]);
            day = max(day, tmp);
        }
        cout << cnt << " " << day << endl;
    }
    
    return 0;
}
0