Submission #632463

#TimeUsernameProblemLanguageResultExecution timeMemory
632463MahdiJail (JOI22_jail)C++17
0 / 100
1 ms212 KiB
#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 (stderr)

jail.cpp: In function 'void sol()':
jail.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i+1<b.size();++i){
      |                 ~~~^~~~~~~~~
jail.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=0;i+1<c.size();++i){
      |                 ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...