結果

問題 No.812 Change of Class
ユーザー ngtkanangtkana
提出日時 2020-03-30 22:11:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 199 ms / 4,000 ms
コード長 1,048 bytes
コンパイル時間 3,468 ms
コンパイル使用メモリ 205,044 KB
実行使用メモリ 11,368 KB
最終ジャッジ日時 2023-09-05 08:54:39
合計ジャッジ時間 8,263 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
9,900 KB
testcase_01 AC 11 ms
4,376 KB
testcase_02 AC 40 ms
6,728 KB
testcase_03 AC 86 ms
10,744 KB
testcase_04 AC 77 ms
10,060 KB
testcase_05 AC 199 ms
10,744 KB
testcase_06 AC 151 ms
9,160 KB
testcase_07 AC 5 ms
4,456 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 170 ms
11,316 KB
testcase_10 AC 182 ms
11,228 KB
testcase_11 AC 15 ms
6,984 KB
testcase_12 AC 93 ms
10,132 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 110 ms
8,232 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 100 ms
8,664 KB
testcase_18 AC 77 ms
7,312 KB
testcase_19 AC 87 ms
8,044 KB
testcase_20 AC 184 ms
11,316 KB
testcase_21 AC 73 ms
7,308 KB
testcase_22 AC 33 ms
5,136 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 9 ms
4,376 KB
testcase_25 AC 26 ms
4,684 KB
testcase_26 AC 147 ms
9,472 KB
testcase_27 AC 121 ms
8,844 KB
testcase_28 AC 84 ms
7,752 KB
testcase_29 AC 20 ms
4,380 KB
testcase_30 AC 110 ms
8,608 KB
testcase_31 AC 98 ms
7,764 KB
testcase_32 AC 40 ms
5,496 KB
testcase_33 AC 127 ms
9,136 KB
testcase_34 AC 8 ms
4,380 KB
testcase_35 AC 20 ms
4,580 KB
testcase_36 AC 8 ms
4,380 KB
testcase_37 AC 52 ms
5,852 KB
testcase_38 AC 7 ms
4,728 KB
testcase_39 AC 54 ms
5,808 KB
testcase_40 AC 13 ms
4,380 KB
testcase_41 AC 5 ms
4,516 KB
testcase_42 AC 117 ms
8,600 KB
testcase_43 AC 22 ms
6,636 KB
testcase_44 AC 81 ms
7,288 KB
testcase_45 AC 8 ms
4,380 KB
testcase_46 AC 21 ms
6,596 KB
testcase_47 AC 80 ms
7,148 KB
testcase_48 AC 86 ms
7,956 KB
testcase_49 AC 22 ms
4,376 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 24 ms
4,880 KB
testcase_52 AC 50 ms
7,216 KB
testcase_53 AC 15 ms
4,380 KB
testcase_54 AC 13 ms
4,380 KB
testcase_55 AC 48 ms
8,932 KB
testcase_56 AC 64 ms
9,992 KB
testcase_57 AC 71 ms
10,624 KB
testcase_58 AC 35 ms
6,936 KB
testcase_59 AC 73 ms
11,368 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 2 ms
4,384 KB
testcase_62 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::vector<std::vector<lint>>g(n);
    while(m--){
        lint p,q;std::cin>>p>>q;p--,q--;
        g.at(p).push_back(q);
        g.at(q).push_back(p);
    }
    lint q;std::cin>>q;
    while(q--){
        lint r;std::cin>>r;r--;
        std::vector<lint>dist(n,-1),que={r};
        dist.at(r)=0;
        for(lint i=0;i<(lint)que.size();i++){
            lint x=que.at(i);
            for(lint y:g.at(x)){
                if(dist.at(y)!=-1)continue;
                dist.at(y)=dist.at(x)+1;
                que.push_back(y);
            }
        }
        lint sz=std::count_if(dist.begin(),dist.end(),[](lint x){return x!=-1;});
        lint d=*std::max_element(dist.begin(),dist.end());
        std::cout<<sz-1<<' '<<(d<=1?0:std::numeric_limits<lint>::digits-__builtin_clzll(d-1)+1)<<'\n';
    }
}
0