# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
632455 |
2022-08-20T05:27:30 Z |
Mahdi |
Jail (JOI22_jail) |
C++17 |
|
0 ms |
212 KB |
#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;
const int N=12e4+5;
int n, m, a[N];
void sol(){
cin>>n;
for(int i=1;i<n;++i){
int u, v;
cin>>u>>v;
}
priority_queue<pii>pq, qp;
cin>>m;
for(int i=0;i<m;++i){
int u, v;
cin>>u>>v;
if(u<v)
pq.push({-u+1, v});
else
qp.push({-v+1, u});
}
memset(a, -1, 4*n);
int r1=0, r2=0;
for(int i=0;i<n;++i){
while(!pq.empty() && -pq.top().F<=i){
r1=max(r1, pq.top().S);
pq.pop();
}
while(!qp.empty() && -qp.top().F<=i){
r2=max(r2, qp.top().S);
qp.pop();
}
if(r1>i)
a[i]=0;
if(r2>i){
if(a[i]==0){
cout<<"NO\n";
return;
}
a[i]=1;
}
}
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 |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |