Submission #55734


ソースコード

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
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m,r,a,b,count=1;
cin>>n>>m>>r;
vint flag(n+10,0);
flag[m-1]=1;
rep(i,r){
cin>>a>>b;
if(flag[a-1]==1 && flag[b-1]==0){
count++;
flag[b-1]=1;
}
else if(flag[a-1]==0 && flag[b-1]==1){
count++;
flag[a-1]=1;
}
}
cout<<count<<'\n';
return(0);
}

ステータス

項目 データ
問題 1188 - マジック
ユーザー名 ei1918
投稿日時 2019-10-24 17:07:35
言語 C++
状態 Accepted
得点 1
ソースコード長 1149 Byte
最大実行時間 24 ms
最大メモリ使用量 644 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 24 ms 604 KB
1
in02.text AC 24 ms 432 KB
1
in03.text AC 18 ms 516 KB
1
in04.text AC 19 ms 472 KB
1
in05.text AC 23 ms 552 KB
1
in06.text AC 23 ms 636 KB
1
in07.text AC 18 ms 592 KB
1
sample1.text AC 20 ms 552 KB
1
sample2.text AC 20 ms 644 KB
1
sample3.text AC 23 ms 604 KB
1