Submission #66802


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,n,x) for(int (i)=(n);(i)>=(int)(x);(i)--)
#define vi vector<int>
#define vc vector<char>
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define P pair<int,int>
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n,m,c; cin>>n>>m>>c;
vector<int> ed[n+1];
for(int i=1;i<=m;i++){
int a,b; cin>>a>>b;
ed[a].push_back(b);
ed[b].push_back(a);
}
vector<int> kt(n+1);
for(int i=1;i<=n;i++){
queue<P> q;
int count=0;
vector<bool> flag(n+1,true);
q.emplace(i,0);
flag[i]=false;
while(!q.empty()){
int node,cost;
tie(node,cost)=q.front();
q.pop();
count++;
if(cost>=c) continue;
for(auto to:ed[node]){
if(flag[to]){
q.emplace(to,cost+1);
flag[to]=false;
}
}
}
kt[i]=count-1;
}
for(int i=1;i<=n;i++){
cout<<kt[i]<<"\n";
}
return 0;
}

ステータス

項目 データ
問題 1406 - 友達の友達は友達?
ユーザー名 ei2005
投稿日時 2021-06-04 18:03:59
言語 C++17
状態 Accepted
得点 1
ソースコード長 1328 Byte
最大実行時間 40 ms
最大メモリ使用量 952 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 38 ms 604 KB
1
in02.text AC 40 ms 564 KB
1
in03.text AC 25 ms 652 KB
1
in04.text AC 33 ms 736 KB
1
in05.text AC 26 ms 560 KB
1
in06.text AC 22 ms 644 KB
1
in07.text AC 20 ms 712 KB
1
in08.text AC 19 ms 496 KB
1
in09.text AC 26 ms 568 KB
1
in10.text AC 32 ms 636 KB
1
in11.text AC 22 ms 680 KB
1
in12.text AC 23 ms 748 KB
1
in13.text AC 21 ms 664 KB
1
in14.text AC 33 ms 720 KB
1
in15.text AC 37 ms 752 KB
1
in16.text AC 20 ms 776 KB
1
in17.text AC 27 ms 812 KB
1
in18.text AC 18 ms 744 KB
1
in19.text AC 27 ms 824 KB
1
in20.text AC 21 ms 772 KB
1
in21.text AC 34 ms 700 KB
1
in22.text AC 36 ms 740 KB
1
in23.text AC 21 ms 660 KB
1
in24.text AC 24 ms 864 KB
1
in25.text AC 21 ms 796 KB
1
in26.text AC 28 ms 740 KB
1
in27.text AC 27 ms 796 KB
1
in28.text AC 33 ms 864 KB
1
in29.text AC 19 ms 912 KB
1
in30.text AC 34 ms 952 KB
1
samplein01.text AC 30 ms 848 KB
1
samplein02.text AC 19 ms 804 KB
1