Submission #00077
ソースコード
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 | #include<iostream> using namespace std; int main() { int n,m; cin >> n >> m; int data[m][2]; bool fnd1[n+1]; bool judge = false ; for ( int i = 0;i < n+1;i++)fnd1[i] = false ; for ( int i = 0;i < m;i++){ cin >> data[i][0] >> data[i][1]; if (data[i][0] == 1)fnd1[data[i][1]] = true ; if (data[i][1] == 1)fnd1[data[i][0]] = true ; } //for(int i = 0;i < n+1;i++)cout << fnd1[i] << endl; //cout << endl; for ( int i = 1;i < n+1;i++){ if (fnd1[i] == true ){ for ( int j = 0;j < m;j++){ judge = false ; if (data[j][0] == i){ for ( int a = 0;a < m;a++){ if ((data[a][0] == 1 && data[a][1] == i) || (data[a][0] == i && data[a][1] == 1)){ judge = true ; } } if (judge)fnd1[data[j][1]] = true ; } else if (data[j][1] == i){ for ( int a = 0;a < m;a++){ if ((data[a][0] == 1 && data[a][1] == i) || (data[a][0] == i && data[a][1] == 1)){ judge = true ; } } if (judge)fnd1[data[j][0]] = true ; } } } } fnd1[1] = false ; //for(int i = 0;i < n+1;i++)cout << fnd1[i] << endl; //cout << endl; int cnt = 0; for ( int i = 1;i < n+1;i++){ if (fnd1[i] == true )cnt++; } cout << cnt << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - パーティ |
ユーザー名 | ei1507 |
投稿日時 | 2015-11-12 17:56:39 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 1233 Byte |
最大実行時間 | 77 ms |
最大メモリ使用量 | 708 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 | 16 ms | 476 KB |
1
|
||||
in2.txt | AC | 11 ms | 708 KB |
2
|
||||
in3.txt | AC | 10 ms | 556 KB |
3
|
||||
in4.txt | AC | 13 ms | 404 KB |
4
|
||||
in5.txt | AC | 77 ms | 636 KB |
5
|