Submission #64100


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define fi first
#define se second
#define mp make_pair
signed main(){
int n,m,c;
cin >>n>>m>>c;
vector<vector<int>> cone(n);
for(int i=0;i<m;i++){
int a,b;cin >>a>>b;
a--,b--;
cone[a].emplace_back(b);
cone[b].emplace_back(a);
}
for(int i=0;i<n;i++){
set<int> ans;
queue<pair<int,int>> q;
q.push(mp(1,i));
ans.insert(i);
while(!q.empty()){
int point,pi;
tie(point,pi)=q.front();
q.pop();
if(point>c) break;
for(int j=0;j<cone[pi].size();j++){
if(ans.find(cone[pi][j])==ans.end()){
q.push(mp(point+1,cone[pi][j]));
ans.insert(cone[pi][j]);
}
}
}
cout <<ans.size()-1<<'\n';
}
return(0);
}

ステータス

項目 データ
問題 1406 - 友達の友達は友達?
ユーザー名 ei1923
投稿日時 2020-09-17 15:54:52
言語 C++17
状態 Accepted
得点 1
ソースコード長 822 Byte
最大実行時間 130 ms
最大メモリ使用量 760 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 35 ms 604 KB
1
in02.text AC 24 ms 572 KB
1
in03.text AC 20 ms 672 KB
1
in04.text AC 20 ms 508 KB
1
in05.text AC 17 ms 604 KB
1
in06.text AC 18 ms 576 KB
1
in07.text AC 19 ms 540 KB
1
in08.text AC 17 ms 488 KB
1
in09.text AC 26 ms 576 KB
1
in10.text AC 54 ms 656 KB
1
in11.text AC 22 ms 704 KB
1
in12.text AC 40 ms 528 KB
1
in13.text AC 30 ms 580 KB
1
in14.text AC 106 ms 648 KB
1
in15.text AC 130 ms 680 KB
1
in16.text AC 18 ms 704 KB
1
in17.text AC 48 ms 760 KB
1
in18.text AC 21 ms 564 KB
1
in19.text AC 16 ms 656 KB
1
in20.text AC 35 ms 612 KB
1
in21.text AC 114 ms 552 KB
1
in22.text AC 62 ms 580 KB
1
in23.text AC 18 ms 624 KB
1
in24.text AC 42 ms 584 KB
1
in25.text AC 23 ms 644 KB
1
in26.text AC 19 ms 604 KB
1
in27.text AC 36 ms 672 KB
1
in28.text AC 30 ms 616 KB
1
in29.text AC 22 ms 672 KB
1
in30.text AC 87 ms 600 KB
1
samplein01.text AC 18 ms 468 KB
1
samplein02.text AC 22 ms 568 KB
1