結果

問題 No.812 Change of Class
ユーザー beetbeet
提出日時 2019-04-12 21:33:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 185 ms / 4,000 ms
コード長 1,019 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 208,376 KB
実行使用メモリ 10,412 KB
最終ジャッジ日時 2023-09-03 00:51:09
合計ジャッジ時間 8,409 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
8,116 KB
testcase_01 AC 10 ms
4,384 KB
testcase_02 AC 30 ms
5,812 KB
testcase_03 AC 64 ms
8,924 KB
testcase_04 AC 56 ms
8,340 KB
testcase_05 AC 176 ms
9,436 KB
testcase_06 AC 143 ms
8,264 KB
testcase_07 AC 5 ms
4,432 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 169 ms
9,784 KB
testcase_10 AC 176 ms
9,748 KB
testcase_11 AC 16 ms
6,944 KB
testcase_12 AC 103 ms
9,192 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 103 ms
7,268 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 96 ms
7,952 KB
testcase_18 AC 73 ms
6,460 KB
testcase_19 AC 82 ms
7,080 KB
testcase_20 AC 185 ms
9,908 KB
testcase_21 AC 69 ms
6,464 KB
testcase_22 AC 31 ms
4,572 KB
testcase_23 AC 6 ms
4,380 KB
testcase_24 AC 10 ms
4,384 KB
testcase_25 AC 25 ms
4,380 KB
testcase_26 AC 146 ms
8,560 KB
testcase_27 AC 117 ms
7,940 KB
testcase_28 AC 81 ms
7,076 KB
testcase_29 AC 19 ms
4,380 KB
testcase_30 AC 104 ms
7,808 KB
testcase_31 AC 87 ms
7,092 KB
testcase_32 AC 39 ms
5,288 KB
testcase_33 AC 111 ms
8,388 KB
testcase_34 AC 8 ms
4,384 KB
testcase_35 AC 20 ms
4,384 KB
testcase_36 AC 8 ms
4,384 KB
testcase_37 AC 50 ms
5,476 KB
testcase_38 AC 7 ms
4,884 KB
testcase_39 AC 51 ms
5,160 KB
testcase_40 AC 13 ms
4,380 KB
testcase_41 AC 5 ms
4,744 KB
testcase_42 AC 113 ms
7,476 KB
testcase_43 AC 24 ms
6,252 KB
testcase_44 AC 73 ms
6,228 KB
testcase_45 AC 9 ms
4,380 KB
testcase_46 AC 21 ms
6,156 KB
testcase_47 AC 72 ms
6,528 KB
testcase_48 AC 81 ms
6,952 KB
testcase_49 AC 21 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 22 ms
4,696 KB
testcase_52 AC 44 ms
6,548 KB
testcase_53 AC 14 ms
4,380 KB
testcase_54 AC 12 ms
4,384 KB
testcase_55 AC 54 ms
8,244 KB
testcase_56 AC 64 ms
9,304 KB
testcase_57 AC 67 ms
9,464 KB
testcase_58 AC 35 ms
6,632 KB
testcase_59 AC 77 ms
10,412 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<vector<Int> > G(n);
  for(Int i=0;i<m;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  Int q;
  cin>>q;
  while(q--){
    Int s;
    cin>>s;
    s--;
    Int cnt=0;
    vector<Int> dist(n,-1);
    queue<Int> q;
    dist[s]=0;
    q.emplace(s);
    while(!q.empty()){
      Int v=q.front();q.pop();      
      cnt++;
      for(Int u:G[v]){
        if(~dist[u]) continue;
        dist[u]=dist[v]+1;
        q.emplace(u);
      }
    }
    Int d=*max_element(dist.begin(),dist.end());
    Int ans=0;
    while(d>(1<<ans)) ans++;
    cout<<cnt-1<<" "<<ans<<endl;
  }
  return 0;
}
0