Submission #56771


ソースコード

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 int long long
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
int c=max(a,b)-min(a,b);
return c;
}
int gcd(int a,int b){//最大公約数
int c=a%b;
while(true){
if(c==0) break;
a=b;
b=c;
c=a%b;
}
return b;
}
bool IsPrime(int num){
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false;
double sqrtNum = sqrt(num);
for(int i=3;i<=sqrtNum;i+=2){
if(num%i==0){
return false;
}
}
}
int lcm(int a,int b){//最小公倍数
return (a*b)/gcd(a,b);
}
signed main(){
// __builtin_ctz(N); Nを2で何回割り切れるかを返す
//(n+1)*n/2; 1からNまでの総和を求める式
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,c,e,f;
int sum=0;
vector<pair<int,int> > d;
int date[1000]={};
cin>>a>>b>>c;
for(int i=0;i<c;i++){
cin>>f>>e;
d.push_back(make_pair(f,e));
}
date[b]=1;
//for(int i=0;i<=a;i++){
for(int j=0;j<c;j++){
if(date[d[j].fi]==1||date[d[j].se]==1) date[d[j].fi]=1,date[d[j].se]=1;
}
//}
for(int i=0;i<=a;i++) sum+=date[i];
cout<<sum<<"\n";
}

ステータス

項目 データ
問題 1188 - マジック
ユーザー名 ei1941
投稿日時 2019-11-23 11:13:15
言語 C++14
状態 Accepted
得点 1
ソースコード長 1451 Byte
最大実行時間 28 ms
最大メモリ使用量 652 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 28 ms 600 KB
1
in02.text AC 22 ms 424 KB
1
in03.text AC 20 ms 500 KB
1
in04.text AC 15 ms 440 KB
1
in05.text AC 20 ms 652 KB
1
in06.text AC 24 ms 608 KB
1
in07.text AC 24 ms 560 KB
1
sample1.text AC 21 ms 508 KB
1
sample2.text AC 19 ms 592 KB
1
sample3.text AC 20 ms 552 KB
1