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>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef pair<int, int> pii;
typedef long long ll;
int n, m;
void sol(){
cin>>n;
for(int i=1;i<n;++i){
int u, v;
cin>>u>>v;
}
cin>>m;
vector<pii>a;
for(int i=0;i<m;++i){
int u, v;
cin>>u>>v;
a.push_back({--u, --v});
}
sort(all(a));
for(int i=0;i<m-1;++i){
if(a[i].S>=a[i+1].S){
cout<<"NO\n";
return;
}
}
cout<<"YES\n";
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int T;
cin>>T;
while(T--)
sol();
}
# | 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... |