結果
問題 | No.806 木を道に |
ユーザー | cider |
提出日時 | 2019-03-22 22:03:37 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 1,949 bytes |
コンパイル時間 | 1,729 ms |
コンパイル使用メモリ | 172,508 KB |
実行使用メモリ | 9,420 KB |
最終ジャッジ日時 | 2023-10-19 09:12:19 |
合計ジャッジ時間 | 3,647 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 2 ms
4,348 KB |
testcase_10 | AC | 18 ms
4,684 KB |
testcase_11 | AC | 16 ms
4,420 KB |
testcase_12 | AC | 74 ms
8,116 KB |
testcase_13 | AC | 51 ms
6,796 KB |
testcase_14 | AC | 69 ms
7,852 KB |
testcase_15 | AC | 73 ms
8,116 KB |
testcase_16 | AC | 25 ms
4,948 KB |
testcase_17 | AC | 62 ms
7,588 KB |
testcase_18 | AC | 7 ms
4,348 KB |
testcase_19 | AC | 19 ms
4,684 KB |
testcase_20 | AC | 63 ms
7,588 KB |
testcase_21 | AC | 34 ms
5,740 KB |
testcase_22 | AC | 86 ms
8,908 KB |
testcase_23 | AC | 86 ms
8,908 KB |
testcase_24 | AC | 39 ms
6,268 KB |
testcase_25 | AC | 58 ms
7,852 KB |
testcase_26 | AC | 22 ms
5,380 KB |
testcase_27 | AC | 68 ms
9,420 KB |
testcase_28 | AC | 3 ms
4,348 KB |
ソースコード
#include<bits/stdc++.h> //#define int long long #define FOR(i, a, b) for (int i = a; i < b; ++i) #define rep(N) for (int i = 0; i < N; ++i) #define Rep(a, b) for (int i = a; i < b; ++i) #define For(i, N) for (int i = 0; i < N; ++i) #define all(v) v.begin(), v.end() #define rev(v) v.rbegin(), v.rend() #define makei(N) int N; cin >> N; #define makes(s) string s; cin >> s; #define maked(d) double d; cin >> d; #define makev(v, N) vi v(N); rep(N)cin >> v[i]; #define mod 1000000007 using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vll = vector<ll>; using vb = vector<bool>; using vvb = vector<vector<bool>>; using vs = vector<string>; using pii = pair<int, int>; using pis = pair<int, string>; using msi = map<string, int>; template<typename T> void say(T s) { cout << s << "\n"; } template<typename T> void say(vector<T> s) { auto itr = s.begin(); cout << *(itr++); while (itr != s.end()) { cout << " " << *(itr++); } cout << "\n"; } template<typename T> void say(vector<T> s, char r) { auto itr = s.begin(); cout << *(itr++); while (itr != s.end()) { cout << r << *(itr++); } cout << "\n"; } void yn(bool b) { if (b)say("yes"); else say("no"); } void Yn(bool b) { if (b)say("Yes"); else say("No"); } void YN(bool b) { if (b)say("YES"); else say("NO"); } template<typename T> void maxi(T& a, T b) { a = max(a, b); } template<typename T> void mini(T& a, T b) { a = min(a, b); } void exact_say(double x) { cout << setprecision(numeric_limits<double>::max_digits10) << x << endl; } template<typename T> vector<vector<T>> fill_vector(int h, int w, T val) { vector<vector<T>> ret; vector<T> v(w, val); rep(h)ret.push_back(v); return ret; } signed main() { ll ans = 0; makei(n); vvi v(n); rep(n - 1) { makei(a); makei(b); --a; --b; v[a].push_back(b); v[b].push_back(a); } for (vi x : v) { ans += max(0, ((int)x.size()) - 2); } say(ans); }