# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
632463 | 2022-08-20T05:46:31 Z | Mahdi | Jail (JOI22_jail) | C++17 | 1 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]; vector<pii>b, c; void sol(){ cin>>n; for(int i=1;i<n;++i){ int u, v; cin>>u>>v; } cin>>m; b.clear(); c.clear(); fill(a, a+n, -1); bool th=1; for(int i=0;i<m;++i){ int u, v; cin>>u>>v; if(u<v){ for(int j=u;j<v;++j){ if(a[j]==1) th=0; a[j]=0; } b.push_back({u, v}); } else{ for(int j=v;j<u;++j){ if(a[j]==0) th=0; a[j]=1; } c.push_back({v, u}); } } sort(all(b)); sort(all(c)); for(int i=0;i+1<b.size();++i){ if(b[i].S>b[i+1].S) th=0; } for(int i=0;i+1<c.size();++i){ if(c[i].S>c[i+1].S) th=0; } if(th) cout<<"YES\n"; else cout<<"NO\n"; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int T; cin>>T; while(T--) sol(); }
Compilation message
# | 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 | 1 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 | - |