# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
884907 |
2023-12-08T16:27:38 Z |
Ahmed57 |
Jail (JOI22_jail) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
int bit[120001];
int n;
void add(int e){
while(e<=n){
bit[e]++;
e+=e&-e;
}
}
int sum(int e){
int su = 0;
while(e>=1){
su+=bit[e];
e-=e&-e;
}
return su;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t;cin>>t;
z:while(t--){
cin>>n;
for(int i = 1;i<=n;i++)bit[i] = 0;
for(int i = 1;i<n;i++){
int a,b;cin>>a>>b;
}
int q;cin>>q;
vector<pair<int,int>> qu;
for(int i = 1;i<=q;i++){
int a,b;
cin>>a>>b;
if(a>b)swap(a,b);
qu.push_back({a,b});
}
sort(qu.begin(),qu.end());
for(auto i:qu){
if(sum(n)-sum(i.second)>0){
cout<<"No\n";
continue;
}
add(i.second);
}
cout<<"Yes\n";
}
return 0;
}
Compilation message
jail.cpp: In function 'int main()':
jail.cpp:25:5: warning: label 'z' defined but not used [-Wunused-label]
25 | z:while(t--){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |