結果
| 問題 | No.1582 Vertexes vs Edges |
| コンテスト | |
| ユーザー |
uzzy
|
| 提出日時 | 2021-07-03 04:37:20 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 1,067 bytes |
| 記録 | |
| コンパイル時間 | 2,912 ms |
| コンパイル使用メモリ | 231,112 KB |
| 実行使用メモリ | 9,216 KB |
| 最終ジャッジ日時 | 2026-03-08 21:47:24 |
| 合計ジャッジ時間 | 5,482 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please
vector<int> E[100100];
pair<int, int> dfs(int u, int mae) {
int ret1 = 0, ret2 = 1;
for (auto to : E[u]) if (to != mae) {
auto p = dfs(to, u);
ret1 += p.second;
ret2 += min(p.first, p.second);
}
return mp(ret1, ret2);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
rep(i, N - 1) {
int u, v;
cin >> u >> v;
E[u].pb(v);
E[v].pb(u);
}
auto p = dfs(1, -1);
co(min(p.second, p.first));
Would you please return 0;
}
uzzy