結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-22 22:53:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 570 bytes |
| コンパイル時間 | 709 ms |
| コンパイル使用メモリ | 83,720 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 06:18:47 |
| 合計ジャッジ時間 | 2,219 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:13: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | cout << ans << endl;
| ^~~
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <limits>
#include <iomanip>
using namespace std;
int main() {
int n;
int ans;
cin >> n;
vector<int> status(n);
for(int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
status[a-1] += 1;
status[b-1] += 1;
}
for(int i = 0; i < n; i++) {
if(status[i] > 2) {
ans += status[i] - 2;
}
}
cout << ans << endl;
}