Submission #00018
ソースコード
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 | #include<bits/stdc++.h> using namespace std; int main(){ int n,m,i,j,ans=0; scanf ( "%d %d" ,&n,&m); int li[n]={0}; int a[m],b[m]; for (i=0;i<m;i++){ scanf ( "%d %d" ,&a[i],&b[i]); if (a[i]==1){ li[b[i]-1]=1; } } for (i=0;i<m-1;i++){ for (j=0;j<m-1-i;j++){ if (a[j]>a[j+1]){ int temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; temp=b[j]; b[j]=b[j+1]; b[j+1]=temp; } } } for (i=0;i<m;i++){ if (li[a[i]-1]==1&&li[b[i]-1]!=1){ li[b[i]-1]=2; } else if (li[b[i]-1]==1&&li[a[i]-1]!=1){ li[a[i]-1]=2; } } for (i=1;i<n;i++){ if (li[i]==1||li[i]==2){ ans++; } } printf ( "%d\n" ,ans); return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - パーティ |
ユーザー名 | ei1620 |
投稿日時 | 2017-11-04 14:57:34 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 714 Byte |
最大実行時間 | 131 ms |
最大メモリ使用量 | 512 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | in1 | 20 / 20 | in1.txt |
2 | in2 | 20 / 20 | in2.txt |
3 | in3 | 20 / 20 | in3.txt |
4 | in4 | 20 / 20 | in4.txt |
5 | in5 | 20 / 20 | in5.txt |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | ||||
---|---|---|---|---|---|---|---|---|
in1.txt | AC | 12 ms | 480 KB |
1
|
||||
in2.txt | AC | 18 ms | 460 KB |
2
|
||||
in3.txt | AC | 22 ms | 436 KB |
3
|
||||
in4.txt | AC | 23 ms | 412 KB |
4
|
||||
in5.txt | AC | 131 ms | 512 KB |
5
|