mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 19:28:48 +00:00
parent
f130022441
commit
216abf2db0
91
LibreOJ/2482/2482.cpp
Normal file
91
LibreOJ/2482/2482.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e6 + 5;
|
||||
|
||||
int n, t, m, fa[N], sum[N], f[N], ans;
|
||||
bool vis[N];
|
||||
std::vector<int> g[N];
|
||||
|
||||
void dfs(int u, int _f) {
|
||||
int max1 = 0, max2 = 0;
|
||||
|
||||
fa[u] = _f;
|
||||
|
||||
if (u != t) {
|
||||
sum[u] = sum[_f] + g[u].size() - 1 - (u != m);
|
||||
}
|
||||
|
||||
for (const int &v : g[u]) {
|
||||
if (v == _f) continue;
|
||||
|
||||
dfs(v, u);
|
||||
|
||||
if (f[v] > max1) {
|
||||
max2 = max1;
|
||||
max1 = f[v];
|
||||
} else if (f[v] > max2) {
|
||||
max2 = f[v];
|
||||
}
|
||||
}
|
||||
|
||||
f[u] = max2 + g[u].size() - 1;
|
||||
}
|
||||
|
||||
bool check(int x) {
|
||||
for (int i = m, cnt = 1; i != t; i = fa[i], cnt++) {
|
||||
int t = 0;
|
||||
|
||||
for (const int &v : g[i]) {
|
||||
if (vis[v] || sum[i] + f[v] <= x) continue;
|
||||
if (!cnt) return false;
|
||||
|
||||
t++, cnt--;
|
||||
}
|
||||
|
||||
x -= t;
|
||||
}
|
||||
|
||||
return x >= 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> t >> m;
|
||||
|
||||
for (int i = 1, u, v; i < n; i++) {
|
||||
cin >> u >> v;
|
||||
|
||||
g[u].push_back(v);
|
||||
g[v].push_back(u);
|
||||
}
|
||||
|
||||
dfs(t, 0);
|
||||
|
||||
for (int i = m; i; i = fa[i]) {
|
||||
vis[i] = true;
|
||||
}
|
||||
|
||||
int l = 0, r = n << 1;
|
||||
|
||||
while (l <= r) {
|
||||
int mid = l + r >> 1;
|
||||
|
||||
if (check(mid)) {
|
||||
r = mid - 1;
|
||||
ans = mid;
|
||||
} else {
|
||||
l = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
LibreOJ/2482/data/config.yml
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/config.yml
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.01.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.01.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.01.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.01.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.02.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.02.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.02.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.02.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.03.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.03.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.03.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.03.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.04.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.04.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.04.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.04.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.05.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.05.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.05.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.05.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.06.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.06.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.06.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.06.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.07.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.07.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.07.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.07.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.08.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.08.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.08.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.08.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.09.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.09.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.09.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.09.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.10.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.01.10.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.01.10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.01.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.01.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.01.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.01.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.02.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.02.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.02.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.02.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.03.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.03.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.03.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.03.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.04.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.04.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.04.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.04.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.05.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.05.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.05.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.05.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.06.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.06.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.02.06.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.02.06.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.01.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.01.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.01.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.01.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.02.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.02.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.02.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.02.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.03.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.03.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.03.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.03.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.04.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.04.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.04.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.04.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.05.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.05.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.05.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.05.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.06.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.06.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.06.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.06.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.07.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.07.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.07.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.07.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.08.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.08.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.08.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.08.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.09.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.09.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.09.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.09.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.10.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.10.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.11.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.11.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.12.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.03.12.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.03.12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.01.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.01.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.01.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.01.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.02.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.02.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.02.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.02.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.03.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.03.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.03.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.03.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.04.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.04.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.04.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.04.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.05.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.05.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.05.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.05.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.06.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.06.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.06.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.06.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.07.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.07.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.07.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.07.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.08.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.08.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.08.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.08.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.09.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.09.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.09.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.09.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.10.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.10.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.11.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.11.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.12.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2482/data/trap.04.12.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2482/data/trap.04.12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user