結果
問題 |
No.806 木を道に
|
ユーザー |
|
提出日時 | 2019-03-22 22:53:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 570 bytes |
コンパイル時間 | 759 ms |
コンパイル使用メモリ | 85,644 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 06:18:49 |
合計ジャッジ時間 | 2,041 ms |
ジャッジサーバーID (参考情報) |
judge3 / 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; }