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;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
void solve(){
int n;cin>>n;
for(int i=0;i<n-1;i++){
int a,b;cin>>a>>b;
}
vector<pair<int,int> > arr;
int m;cin>>m;
for(int i=0;i<m;i++){
int s,t;cin>>s>>t;
arr.push_back({s,t});
}
sort(arr.begin(),arr.end());
for(int i=1;i<m;i++){
if(arr[i].second<arr[i].first){
cout<<"No\n";
return;
}
}
cout<<"Yes\n";
return ;
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.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... |