# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
579486 | AriaH | Jail (JOI22_jail) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* Ignore Others Only Focus On Yourself! */
/* Im the Best! */
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define Mp make_pair
#define point complex
#define endl '\n'
#define SZ(x) (int)x.size()
#define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file_io freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define mashtali return cout << "Hello, World!", 0;
const int N = 1e6 + 10;
const int LOG = 20;
const ll mod = 1e9 + 7;
const ll inf = 8e18;
const double pi = acos(-1);
const ld eps = 1e-18;
const ld one = 1.;
ll pw(ll a, ll b, ll M, ll ret = 1) { if(a == 0) return 0; a %= M; while(b) { ret = (b & 1? ret * a % M : ret), a = a * a % M, b >>= 1; } return ret % M; }
mt19937 rng(time(nullptr));
int n, m, sub[N], H[N], P[N], Hd[N], Hv[N], S[N], T[N], start[N], end[N];
vector < int > G[N], adj[N], adt[N];
void dfs(int v)
{
sub[v] = 1;
H[v] = H[P[v]] + 1;
for(auto u : G[v])
{
if(u == P[v]) continue;
P[u] = v;
dfs(u);
if(sub[Hv[v]] < sub[u])
{
Hv[v] = u;
}
}
}
void Hld(int v)
{
if(Hv[v])
{
Hd[Hv[v]] = Hd[v];
dfs(Hv[v]);
}
for(auto u : G[v])
{
if(u == P[v] || u == Hv[v]) continue;
Hd[u] = u;
Hld(u);
}
}
int main()
{
fast_io;
cin >> n;
for(int i = 1; i < n; i ++)
{
int a, b;
cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
dfs(1, 0);
Hld(Hd[1] = 1);
cin >> m;
for(int i = 1; i <= m; i ++)
{
cin >> S[i] >> T[i];
start[S[i]] = i;
end[T[i]] = i;
}
for(int i = 1; i <= m; i ++)
{
vector < int > path;
int v = S[i], u = T[i];
while(v != )
}
return 0;
}
/* check corner case(n = 1?), watch for negetive index or overflow */