#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define all(m) (m).begin(), (m).end()
#define rall(m) (m).rbegin(), (m).rend()
#define vec vector
#define sz(a) (int) (a).size()
#define mpp make_pair
#define mtt make_tuple
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tui;
template <typename T>
using prq = priority_queue <T>;
template <typename T>
using pgq = priority_queue <T, vec <T>, greater <T>>;
template <typename T> bool umin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> bool umax(T &a, T b) { return a < b ? a = b, 1 : 0; }
const int L = 17;
inline int solve(){
int n; cin >> n;
vec <vec <int>> g(n);
for (int i = 0; i < n - 1; ++i){
int u, v;
cin >> u >> v, --u, --v;
g[u].push_back(v);
g[v].push_back(u);
}
vec <vec <int>> up(n, vec <int> (L));
vec <int> fi(n), fo(n);
int tmr = 0;
auto dfs = [&](auto &&dfs, int u, int p) -> void{
up[u][0] = p;
for (int i = 1; i < L; ++i){
up[u][i] = up[up[u][i - 1]][i - 1];
}
fi[u] = tmr++;
for (auto &v: g[u]) if (v != p){
dfs(dfs, v, u);
}
fo[u] = tmr;
};
dfs(dfs, 0, 0);
auto par = [&](int u, int v){
return fi[u] <= fi[v] && fo[v] <= fo[u];
};
auto lca = [&](int u, int v){
if (par(u, v)) return u;
if (par(v, u)) return v;
for (int i = L - 1; ~i; --i){
if (!par(up[u][i], v)) u = up[u][i];
}
return up[u][0];
};
auto on_path = [&](int u, int v, int w){
return par(u, v) && par(v, w);
};
int m; cin >> m;
vec <int> s(m), t(m), lc(m);
for (int i = 0; i < m; ++i){
cin >> s[i] >> t[i], --s[i], --t[i];
lc[i] = lca(s[i], t[i]);
}
vec <int> deg(m);
vec <vec <int>> gg(m);
for (int i = 0; i < m; ++i){
for (int j = 0; j < m; ++j){
if (i == j) continue;
if (on_path(lc[i], t[j], s[i]) || on_path(lc[i], t[j], t[i]) ||
on_path(lc[j], s[i], s[j]) || on_path(lc[j], s[i], t[j]))){
gg[i].push_back(j);
++deg[j];
}
}
}
vec <int> bfs;
for (int i = 0; i < m; ++i){
if (deg[i] == 0) bfs.push_back(i);
}
for (int pt = 0; pt < sz(bfs); ++pt){
int u = bfs[pt];
for (auto &v: gg[u]){
if (--deg[v] == 0){
bfs.push_back(v);
}
}
}
cout << (sz(bfs) == m ? "Yes\n" : "No\n");
return 0;
}
inline void precalc(){}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tst = 1; cin >> tst;
precalc();
while(tst--) solve();
return 0;
}
Compilation message
jail.cpp: In function 'int solve()':
jail.cpp:87:77: error: expected primary-expression before ')' token
87 | on_path(lc[j], s[i], s[j]) || on_path(lc[j], s[i], t[j]))){
| ^