結果
問題 | No.806 木を道に |
ユーザー | guricerin |
提出日時 | 2019-03-23 00:55:39 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,260 bytes |
コンパイル時間 | 959 ms |
コンパイル使用メモリ | 103,728 KB |
実行使用メモリ | 9,316 KB |
最終ジャッジ日時 | 2023-10-19 11:40:10 |
合計ジャッジ時間 | 2,651 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 2 ms
4,348 KB |
testcase_08 | AC | 2 ms
4,348 KB |
testcase_09 | AC | 3 ms
4,348 KB |
testcase_10 | AC | 9 ms
4,564 KB |
testcase_11 | AC | 8 ms
4,564 KB |
testcase_12 | AC | 37 ms
8,260 KB |
testcase_13 | AC | 26 ms
6,940 KB |
testcase_14 | AC | 35 ms
7,996 KB |
testcase_15 | AC | 37 ms
8,524 KB |
testcase_16 | AC | 13 ms
5,092 KB |
testcase_17 | AC | 33 ms
7,732 KB |
testcase_18 | AC | 5 ms
4,348 KB |
testcase_19 | AC | 9 ms
4,564 KB |
testcase_20 | AC | 32 ms
7,732 KB |
testcase_21 | AC | 17 ms
5,884 KB |
testcase_22 | AC | 45 ms
9,316 KB |
testcase_23 | AC | 46 ms
9,316 KB |
testcase_24 | AC | 17 ms
6,148 KB |
testcase_25 | AC | 25 ms
7,732 KB |
testcase_26 | AC | 9 ms
5,272 KB |
testcase_27 | AC | 28 ms
9,308 KB |
testcase_28 | AC | 3 ms
4,348 KB |
ソースコード
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define MOD 1000000007 #define int long long using ll = long long; using namespace std; const int INF = 1LL << 50; using P = pair<int, int>; struct Setup { Setup() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } SETUP; template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } else { return false; } } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } else { return false; } } signed main() { int n; cin >> n; vector<vector<int>> graph(n); rep(i, 0, n - 1) { int from, to; cin >> from >> to; from--, to--; graph[from].push_back(to); graph[to].push_back(from); } int leaf = 0; rep(i, 0, n) { if (graph[i].size() == 1) leaf++; } cout << leaf - 2 << endl; }