This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 120005;
int n, a[N], b[N], m;
pair <int, int> s[N], t[N];
void solve() {
cin >> n;
for (int i = 1; i < n; i ++) {
cin >> a[i] >> b[i];
}
cin >> m;
for (int i = 0; i < m; i ++) {
cin >> s[i].first >> t[i].first;
s[i].second = t[i].second = i;
}
sort(s, s + m);
sort(t, t + m);
for (int i = 0; i < m; i ++) {
if (s[i].second != t[i].second) {
cout << "No\n";
return;
}
}
cout << "Yes\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int q;
cin >> q;
while (q --) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |