結果

問題 No.812 Change of Class
ユーザー chocopuuchocopuu
提出日時 2019-04-13 20:05:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 157 ms / 4,000 ms
コード長 1,687 bytes
コンパイル時間 1,752 ms
コンパイル使用メモリ 171,828 KB
実行使用メモリ 12,084 KB
最終ジャッジ日時 2023-09-03 14:51:50
合計ジャッジ時間 7,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
9,928 KB
testcase_01 AC 11 ms
7,072 KB
testcase_02 AC 28 ms
8,252 KB
testcase_03 AC 53 ms
10,400 KB
testcase_04 AC 48 ms
10,196 KB
testcase_05 AC 157 ms
11,260 KB
testcase_06 AC 128 ms
11,292 KB
testcase_07 AC 5 ms
6,648 KB
testcase_08 AC 5 ms
6,548 KB
testcase_09 AC 150 ms
11,272 KB
testcase_10 AC 152 ms
11,152 KB
testcase_11 AC 12 ms
7,704 KB
testcase_12 AC 95 ms
10,564 KB
testcase_13 AC 5 ms
6,548 KB
testcase_14 AC 5 ms
6,620 KB
testcase_15 AC 97 ms
9,356 KB
testcase_16 AC 11 ms
6,848 KB
testcase_17 AC 89 ms
9,632 KB
testcase_18 AC 66 ms
8,756 KB
testcase_19 AC 75 ms
9,156 KB
testcase_20 AC 154 ms
11,284 KB
testcase_21 AC 64 ms
8,824 KB
testcase_22 AC 31 ms
7,416 KB
testcase_23 AC 9 ms
6,700 KB
testcase_24 AC 12 ms
6,900 KB
testcase_25 AC 26 ms
7,312 KB
testcase_26 AC 120 ms
10,460 KB
testcase_27 AC 103 ms
9,864 KB
testcase_28 AC 73 ms
9,360 KB
testcase_29 AC 21 ms
7,152 KB
testcase_30 AC 94 ms
9,640 KB
testcase_31 AC 80 ms
9,168 KB
testcase_32 AC 37 ms
7,768 KB
testcase_33 AC 97 ms
10,100 KB
testcase_34 AC 12 ms
6,780 KB
testcase_35 AC 22 ms
7,376 KB
testcase_36 AC 11 ms
6,884 KB
testcase_37 AC 46 ms
7,816 KB
testcase_38 AC 7 ms
6,856 KB
testcase_39 AC 47 ms
7,856 KB
testcase_40 AC 15 ms
7,008 KB
testcase_41 AC 6 ms
6,736 KB
testcase_42 AC 94 ms
9,424 KB
testcase_43 AC 22 ms
8,048 KB
testcase_44 AC 64 ms
8,640 KB
testcase_45 AC 11 ms
6,824 KB
testcase_46 AC 21 ms
8,008 KB
testcase_47 AC 64 ms
8,496 KB
testcase_48 AC 72 ms
9,140 KB
testcase_49 AC 21 ms
7,440 KB
testcase_50 AC 5 ms
6,600 KB
testcase_51 AC 22 ms
7,276 KB
testcase_52 AC 41 ms
8,324 KB
testcase_53 AC 16 ms
7,100 KB
testcase_54 AC 14 ms
6,984 KB
testcase_55 AC 35 ms
10,236 KB
testcase_56 AC 41 ms
10,836 KB
testcase_57 AC 59 ms
11,148 KB
testcase_58 AC 25 ms
8,716 KB
testcase_59 AC 65 ms
12,084 KB
testcase_60 AC 5 ms
6,456 KB
testcase_61 AC 4 ms
6,616 KB
testcase_62 AC 4 ms
6,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1e18;

int V,E,Q;
vint g[100010];

signed main() {
    IOS();
    cin>>V>>E;
    vint p(E),q(E);
    rep(i,0,E){
        cin>>p[i]>>q[i];
        p[i]--;q[i]--;
        g[p[i]].pb(q[i]);
        g[q[i]].pb(p[i]);
    }
    
    cin>>Q;
    vint a(Q);
    rep(i,0,Q){
        cin>>a[i];
        a[i]--;
        queue<int>que;
        vint dist(100010,INF);
        dist[a[i]]=0;
        que.push(a[i]);
        int ma=0,ans=0;
        while(!que.empty()){
            int now=que.front();
            que.pop();
            ans++;
            for(auto e:g[now]){
                if(dist[e]!=INF)continue;
                dist[e]=dist[now]+1;
                chmax(ma,dist[e]);
                que.push(e);
            }
        }
        int tmp=1,cnt=0;
        while(tmp<ma){tmp<<=1;cnt++;}
        cout<<ans-1<<" "<<cnt<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}
0