結果
問題 | No.806 木を道に |
ユーザー | minami |
提出日時 | 2020-06-12 17:32:23 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,197 bytes |
コンパイル時間 | 1,832 ms |
コンパイル使用メモリ | 93,536 KB |
実行使用メモリ | 8,832 KB |
最終ジャッジ日時 | 2023-09-06 09:21:09 |
合計ジャッジ時間 | 5,585 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,716 KB |
testcase_01 | AC | 4 ms
5,704 KB |
testcase_02 | AC | 4 ms
5,712 KB |
testcase_03 | AC | 3 ms
5,864 KB |
testcase_04 | AC | 4 ms
5,684 KB |
testcase_05 | AC | 4 ms
5,788 KB |
testcase_06 | AC | 3 ms
5,656 KB |
testcase_07 | AC | 3 ms
5,748 KB |
testcase_08 | AC | 3 ms
5,644 KB |
testcase_09 | AC | 3 ms
5,656 KB |
testcase_10 | AC | 10 ms
6,476 KB |
testcase_11 | AC | 10 ms
6,268 KB |
testcase_12 | AC | 36 ms
8,328 KB |
testcase_13 | AC | 28 ms
7,584 KB |
testcase_14 | AC | 37 ms
8,216 KB |
testcase_15 | AC | 38 ms
8,424 KB |
testcase_16 | AC | 14 ms
6,688 KB |
testcase_17 | AC | 33 ms
8,008 KB |
testcase_18 | AC | 6 ms
6,036 KB |
testcase_19 | AC | 10 ms
6,400 KB |
testcase_20 | AC | 33 ms
8,004 KB |
testcase_21 | AC | 18 ms
6,976 KB |
testcase_22 | AC | 43 ms
8,812 KB |
testcase_23 | AC | 46 ms
8,816 KB |
testcase_24 | AC | 17 ms
7,316 KB |
testcase_25 | AC | 25 ms
8,160 KB |
testcase_26 | AC | 10 ms
6,648 KB |
testcase_27 | AC | 28 ms
8,832 KB |
testcase_28 | AC | 4 ms
5,812 KB |
ソースコード
#include <iostream> #include <iomanip> #include <cstdio> #include <queue> #include <cstring> #include <vector> #include <map> #include <algorithm> #include <cctype> #include <cmath> #include <bitset> #include <set> #include <stack> using namespace std; #define REP(i,n) for(int i=0;i<(int)(n);i++) #define RREP(i,n) for(int i=n-1;i>=0;i--) #define FOR(i,k,n) for(int i=(k);i<(int)(n);i++) #define all(i,n) (i),(i+n) int dx4[4]={1,0,-1,0}; int dy4[4]={0,-1,0,1}; int dx8[8]={1,0,-1,1,-1,1,0,-1}; int dy8[8]={1,1,1,0,0,-1,-1,-1}; int dx9[9]={0,1,0,-1,1,-1,1,0,-1}; int dy9[9]={0,1,1,1,0,0,-1,-1,-1}; typedef pair<int, int> P; typedef pair<string, int> SP; typedef long long ll; typedef pair<ll, ll> PLL; const int INF = 1e9; const ll LLINF = 1e18; const int MAX_V = 1e6+1; const ll mod = 1000000007; // << fixed << setprecision // -------------------------------------- int n; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; vector<int> v[100005]; REP(i, n - 1) { int a, b; cin >> a >> b; a--; b--; v[a].push_back(b); v[b].push_back(a); } ll ans = 0; REP(i, n) { if(v[i].size() > 2) ans += v[i].size() - 2; } cout << ans << endl; }