結果

問題 No.812 Change of Class
ユーザー kappybarkappybar
提出日時 2020-04-14 20:02:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 183 ms / 4,000 ms
コード長 1,098 bytes
コンパイル時間 1,911 ms
コンパイル使用メモリ 173,164 KB
実行使用メモリ 9,280 KB
最終ジャッジ日時 2024-04-09 18:07:00
合計ジャッジ時間 7,818 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
7,936 KB
testcase_01 AC 13 ms
6,940 KB
testcase_02 AC 42 ms
6,940 KB
testcase_03 AC 91 ms
8,704 KB
testcase_04 AC 80 ms
8,192 KB
testcase_05 AC 183 ms
8,148 KB
testcase_06 AC 158 ms
7,168 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 167 ms
8,976 KB
testcase_10 AC 176 ms
8,976 KB
testcase_11 AC 17 ms
6,940 KB
testcase_12 AC 116 ms
8,448 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 119 ms
6,944 KB
testcase_16 AC 9 ms
6,944 KB
testcase_17 AC 112 ms
7,168 KB
testcase_18 AC 83 ms
6,940 KB
testcase_19 AC 96 ms
6,940 KB
testcase_20 AC 177 ms
8,672 KB
testcase_21 AC 79 ms
6,944 KB
testcase_22 AC 35 ms
6,944 KB
testcase_23 AC 7 ms
6,940 KB
testcase_24 AC 11 ms
6,944 KB
testcase_25 AC 29 ms
6,944 KB
testcase_26 AC 146 ms
7,808 KB
testcase_27 AC 126 ms
7,376 KB
testcase_28 AC 93 ms
6,944 KB
testcase_29 AC 21 ms
6,944 KB
testcase_30 AC 116 ms
7,040 KB
testcase_31 AC 98 ms
6,944 KB
testcase_32 AC 46 ms
6,944 KB
testcase_33 AC 125 ms
7,552 KB
testcase_34 AC 10 ms
6,940 KB
testcase_35 AC 24 ms
6,944 KB
testcase_36 AC 9 ms
6,944 KB
testcase_37 AC 55 ms
6,944 KB
testcase_38 AC 7 ms
6,944 KB
testcase_39 AC 57 ms
6,944 KB
testcase_40 AC 15 ms
6,944 KB
testcase_41 AC 5 ms
6,944 KB
testcase_42 AC 118 ms
7,204 KB
testcase_43 AC 35 ms
6,944 KB
testcase_44 AC 81 ms
6,944 KB
testcase_45 AC 10 ms
6,944 KB
testcase_46 AC 31 ms
6,940 KB
testcase_47 AC 80 ms
6,940 KB
testcase_48 AC 89 ms
6,940 KB
testcase_49 AC 23 ms
6,944 KB
testcase_50 AC 2 ms
6,944 KB
testcase_51 AC 26 ms
6,944 KB
testcase_52 AC 54 ms
6,944 KB
testcase_53 AC 16 ms
6,944 KB
testcase_54 AC 13 ms
6,940 KB
testcase_55 AC 57 ms
7,588 KB
testcase_56 AC 68 ms
8,196 KB
testcase_57 AC 73 ms
8,680 KB
testcase_58 AC 38 ms
6,940 KB
testcase_59 AC 82 ms
9,280 KB
testcase_60 AC 2 ms
6,944 KB
testcase_61 AC 2 ms
6,940 KB
testcase_62 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const ll INF = 1e14;
const int MOD = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n,vector<int>());
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }  
    int q;
    cin >> q;
    rep(_,q){
        int a;
        cin >> a;
        --a;
        int cnt = 0;
        int d = 0;
        vector<int> day(n,-1);
        queue<int> q;
        q.push(a);
        day[a] = 0;
        while(!q.empty()){
            int now = q.front();
            if(now != a) cnt ++;
            q.pop();
            for(int next:graph[now]){
                if(day[next] >= 0 ) continue;
                day[next] = day[now] + 1;
                d = max(d,day[next]);
                q.push(next);
            }
        }
        int ans = 0;
        int res = 1;
        while(res < d) res *= 2,ans++;
        cout << cnt << " " << ans  << endl;
    }
}
0