結果
問題 | No.806 木を道に |
ユーザー | null_null |
提出日時 | 2019-03-22 22:06:04 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 2,263 bytes |
コンパイル時間 | 1,696 ms |
コンパイル使用メモリ | 170,128 KB |
実行使用メモリ | 12,320 KB |
最終ジャッジ日時 | 2023-10-19 09:14:53 |
合計ジャッジ時間 | 3,872 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,076 KB |
testcase_01 | AC | 4 ms
6,076 KB |
testcase_02 | AC | 3 ms
6,080 KB |
testcase_03 | AC | 4 ms
6,080 KB |
testcase_04 | AC | 4 ms
6,080 KB |
testcase_05 | AC | 4 ms
6,080 KB |
testcase_06 | AC | 4 ms
6,080 KB |
testcase_07 | AC | 4 ms
6,076 KB |
testcase_08 | AC | 4 ms
6,076 KB |
testcase_09 | AC | 4 ms
6,080 KB |
testcase_10 | AC | 20 ms
6,888 KB |
testcase_11 | AC | 18 ms
6,804 KB |
testcase_12 | AC | 80 ms
9,208 KB |
testcase_13 | AC | 59 ms
8,344 KB |
testcase_14 | AC | 78 ms
9,044 KB |
testcase_15 | AC | 83 ms
9,240 KB |
testcase_16 | AC | 28 ms
7,216 KB |
testcase_17 | AC | 71 ms
8,816 KB |
testcase_18 | AC | 9 ms
6,380 KB |
testcase_19 | AC | 21 ms
6,932 KB |
testcase_20 | AC | 73 ms
8,808 KB |
testcase_21 | AC | 40 ms
7,620 KB |
testcase_22 | AC | 97 ms
9,760 KB |
testcase_23 | AC | 96 ms
9,748 KB |
testcase_24 | AC | 41 ms
10,192 KB |
testcase_25 | AC | 61 ms
12,320 KB |
testcase_26 | AC | 22 ms
7,036 KB |
testcase_27 | AC | 66 ms
9,484 KB |
testcase_28 | AC | 5 ms
6,188 KB |
ソースコード
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; // #define int long long #define pb(x) push_back(x) #define m0(x) memset((x), 0, sizeof(x)) #define mm(x) memset((x), -1, sizeof(x)) //container #define ALL(x) (x).begin(), (x).end() #define RALL(a) (a).rbegin(), (a).rend() #define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end()); #define PERM(c) \ sort(ALL(c)); \ for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c))) // debug #define GET_VAR_NAME(variable) #variable #define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl; // bit_macro #define bit(n) (1LL << (n)) #define bitset(a, b) (a) |= (1 << (b)) #define bitunset(a, b) (a) |= ~(1 << (b)) #define bitcheck(a, b) ((((a) >> (b)) & 1) == 1) #define bitcount(a) __builtin_popcountll((a)) //typedef typedef long long lint; typedef unsigned long long ull; typedef complex<long double> Complex; typedef pair<int, int> P; typedef tuple<int, int, int> TP; typedef vector<int> vec; typedef vector<vec> mat; //constant const int INF = (int)1e18; const int MOD = (int)1e9 + 7; const double PI = (double)acos(-1); const double EPS = (double)1e-10; const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1}; const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1}; // template <typename T> void chmax(T &a, T b) { a = max(a, b); } template <typename T> void chmin(T &a, T b) { a = min(a, b); } // inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // struct Accelerate_Cin { Accelerate_Cin() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); }; }; int N; vec G[101010]; int ans = 0; void rec(int n, int pre) { int res = G[n].size(); for (auto x : G[n]) { if (x != pre) rec(x, n); } if (res >= 2) ans += res - 2; } signed main() { cin >> N; for (int i = 0; i < N - 1; i++) { int a, b; cin >> a >> b; a--, b--; G[a].pb(b); G[b].pb(a); } rec(0, -1); cout << ans << endl; return 0; }