結果

問題 No.812 Change of Class
ユーザー tekihei2317tekihei2317
提出日時 2019-04-12 22:41:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 944 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 171,896 KB
実行使用メモリ 10,628 KB
最終ジャッジ日時 2023-09-03 13:49:28
合計ジャッジ時間 8,830 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 6 ms
6,008 KB
testcase_08 AC 5 ms
5,796 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 23 ms
7,340 KB
testcase_12 WA -
testcase_13 AC 3 ms
5,680 KB
testcase_14 AC 4 ms
5,696 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 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 10 ms
6,308 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 9 ms
6,200 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 68 ms
8,980 KB
testcase_56 AC 80 ms
9,660 KB
testcase_57 AC 84 ms
9,840 KB
testcase_58 AC 44 ms
7,756 KB
testcase_59 AC 95 ms
10,628 KB
testcase_60 AC 4 ms
5,740 KB
testcase_61 AC 3 ms
5,688 KB
testcase_62 AC 4 ms
5,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int size=100010;
const int INF=1e9;
vint G[size];
int N,M;

void bfs(int s)
{
    vint dist(N);
    REP(i,N) dist[i]=INF;
    dist[s]=0;
    queue<int> Q;
    Q.push(s);

    while(!Q.empty()){
	int v=Q.front(); Q.pop();
	for(int u:G[v]){
	    if(dist[u]!=INF) continue;
	    dist[u]=dist[v]+1;
	    Q.push(u);
	}
    }

    int cnt=0,day=0;
    REP(i,N){
	if(dist[i]!=INF and dist[i]>0){
	    cnt++;
	    int d=(dist[i]==1?0:(dist[i]+1)/2);
	    day=max(day,d);
	}
    }
    cout<<cnt<<' '<<day<<endl;
}

signed main()
{
    cin>>N>>M;
    REP(i,M){
	int a,b; cin>>a>>b;
	a--; b--;
	G[a].push_back(b);
	G[b].push_back(a);
    }

    int Q; cin>>Q;
    while(Q--){
	int q; cin>>q; q--;
	bfs(q);
    }
}


0