제출 #493859

#제출 시각아이디문제언어결과실행 시간메모리
493859leakedRestore Array (RMI19_restore)C++14
13 / 100
374 ms796 KiB
#include <bits/stdc++.h> #define f first #define s second #define m_p make_pair #define vec vector #define sz(x) (int)(x).size() #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define fast_rmi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; signed main(){ fast_rmi; int n,m; cin>>n>>m; vec<array<int,4>>arr(m); vec<array<int,4>>arrt(m); for(auto &z : arr){ cin>>z[0]>>z[1]>>z[2]>>z[3]; if(z[3]==1) z[2]=z[2]-1; // cout<<"L R "<<z[0]<<' '<<z[1]<<' '<<z[2]<<' '<<"TYPE "<<z[3]<<endl; } arrt=arr; vec<int> a(n,1); for(int i=0;i<n;i++){ int ok=1; int nd=0; for(auto &z : arr){ if(z[0]<=i&&z[1]>=i){ // cout<<"ALOGG "<<z[0]<<' '<<z[1]<<endl; if(z[3]==0 && z[2]){ nd=1; // cout<<"NEED "<<z[0]<<' '<<z[1]<<' '<<z[2]<<endl; } if(z[3]==1 && !z[2]){ ok=0; // cout<<"CHE "<<z[0]<<' '<<z[1]<<endl; } } } if(nd && ok){ a[i]=0; // cout<<"Y "<<i<<endl; for(auto &z : arr){ if(z[0]<=i&&z[1]>=i){ z[2]=max(0,z[2]-1); } } } } auto check=[&](){ int ok=1; for(auto &z : arrt){ int cnt=0; for(int i=z[0];i<=z[1];i++) cnt+=(!a[i]); if(z[3]) assert(cnt<=z[2]); else{ ok&=(cnt>=z[2]); } } return ok; }; if(!check()){ cout<<-1; } else for(auto &z : a) cout<<z<<' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...