# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
271921 | 2020-08-18T07:59:49 Z | AKaan37 | Restore Array (RMI19_restore) | C++17 | 26 ms | 512 KB |
//Bismillahirrahmanirrahim //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█▄█ //█─█─█▄─█▄─█─█─█─█ #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< int,int > PII; typedef pair< int,PII > PIII; typedef pair< int,PIII > PIIII; typedef pair< int,PIIII > PIIIII; #define fi first #define se second #define mp make_pair #define endl "\n" #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=0;i<n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 500005; const lo mod = 1000000007; int n,m,b[li],a[li],k,flag,t; int cev; PIIIII p[li]; string s; vector<int> v; int main(void){ scanf("%d %d",&n,&m); //~ FOR a[i]=-1; for(int i=1;i<=m;i++){ scanf("%d %d %d %d",&p[i].se.se.fi,&p[i].se.se.se.fi,&p[i].se.se.se.se,&p[i].fi); p[i].se.fi=p[i].se.se.se.fi-p[i].se.se.fi+1; } sort(p+1,p+n+1); int ind=-1; for(int i=1;i<=m;i++){ if(p[i].se.se.se.se==1 && p[i].fi==0){ for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){ a[j]=0; } } if(p[i].se.se.se.se!=1 && p[i].fi==1){ for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){ a[j]=1; } } } for(int i=1;i<=m;i++){ if(p[i].se.se.se.se==1 && p[i].fi==1){ for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){ a[j]=1; } } if(p[i].se.se.se.se!=1 && p[i].fi==0){ for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){ a[j]=0; } } } for(int i=1;i<=m;i++){ if(p[i].se.se.se.se==1){ int say=0,tut=0; for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){ if(a[j]==0)say++; tut++; } if(say==0 && p[i].fi==0){printf("-1\n");return 0;} if(say!=tut && p[i].fi==1){printf("-1\n");return 0;} } else{ int say=0,tut=0; for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){ if(a[j]==1)say++; tut++; } if(say==0 && p[i].fi==1){printf("-1\n");return 0;} if(say!=tut && p[i].fi==0){printf("-1\n");return 0;} } } FOR printf("%d ",a[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 26 ms | 512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |