Submission #65125


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,n) for(int i=(x);i<=(n);i++)
#define rrep(i,n,x) for(int i=(n);i>=(x);i--)
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define all(v) v.begin(),v.end()
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n,m,r; cin>>n>>m>>r;
vb ans(n+1,false);
ans[m]=true;
rep(i,1,r){
int a,b; cin>>a>>b;
if(ans[a]||ans[b]) ans[a]=true,ans[b]=true;
}
int sum=0;
rep(i,1,n){
if(ans[i]) sum++;
}
cout<<sum<<"\n";
return 0;
}

ステータス

項目 データ
問題 1188 - マジック
ユーザー名 ei2005
投稿日時 2020-12-24 14:47:46
言語 C++14
状態 Accepted
得点 1
ソースコード長 668 Byte
最大実行時間 43 ms
最大メモリ使用量 596 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 43 ms 476 KB
1
in02.text AC 23 ms 432 KB
1
in03.text AC 41 ms 516 KB
1
in04.text AC 33 ms 476 KB
1
in05.text AC 35 ms 560 KB
1
in06.text AC 24 ms 512 KB
1
in07.text AC 24 ms 596 KB
1
sample1.text AC 41 ms 552 KB
1
sample2.text AC 19 ms 504 KB
1
sample3.text AC 21 ms 588 KB
1