Submission #272478

# Submission time Handle Problem Language Result Execution time Memory
272478 2020-08-18T11:59:35 Z AKaan37 Restore Array (RMI19_restore) C++17
20 / 100
591 ms 608 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> vvv;

inline void f(int sira,vector<int> v){
	if(sira>=n){
		flag=0;
		for(int i=1;i<=m;i++){
			int say=0;
			for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){
				if(v[j]==0)say++;
			}
			if(say>=p[i].se.se.se.se && p[i].fi==0){flag++;}
			if(say<p[i].se.se.se.se && p[i].fi==1){flag++;}
		}
		//~ cout<<flag<<endl;
		if(flag==m){
			for(int i=0;i<n;i++)printf("%d ",v[i]);
			exit(0);
		}
		return ;
	}
	
	f(sira+1,v);
	vector<int> vv=v;
	vv[sira]=1;
	f(sira+1,vv);
}
 
int main(void){
	scanf("%d %d",&n,&m);
	//~ FOR a[i]=-1;
	int yes=0;
	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;
		if(p[i].se.se.se.se==1)yes++;
	}
	sort(p+1,p+m+1);
	if(n>=3000){
		int ind=-1;
		for(int i=1;i<=m;i++){
			if(p[i].fi==1)break;
			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].fi==0)continue;
			if(ind==-1)ind=i-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].fi==1)break;
			int say=0;
			for(int j=p[i].se.se.fi;j<=p[i].se.se.se.fi;j++){
				if(a[j]==0)say++;
			}
			if(say==0){printf("-1\n");return 0;}
		}
		//~ FOR{
			//~ if(a[i]==-1){a[i]=1;}
		//~ }
		
		FOR printf("%d ",a[i]);
		return 0;
	}
	FOR vvv.pb(0);
	f(0,vvv);
	printf("-1\n");
	return 0;
}

Compilation message

restore.cpp: In function 'int main()':
restore.cpp:64:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   64 |  scanf("%d %d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~~
restore.cpp:68:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |   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);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 37 ms 384 KB Output is correct
4 Correct 236 ms 504 KB Output is correct
5 Correct 591 ms 504 KB Output is correct
6 Correct 252 ms 384 KB Output is correct
7 Correct 41 ms 384 KB Output is correct
8 Correct 65 ms 384 KB Output is correct
9 Correct 292 ms 384 KB Output is correct
10 Correct 11 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 512 KB Output is correct
2 Correct 30 ms 608 KB Output is correct
3 Correct 29 ms 580 KB Output is correct
4 Correct 30 ms 512 KB Output is correct
5 Correct 19 ms 596 KB Output is correct
6 Correct 18 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 512 KB Output is correct
2 Correct 30 ms 608 KB Output is correct
3 Correct 29 ms 580 KB Output is correct
4 Correct 30 ms 512 KB Output is correct
5 Correct 19 ms 596 KB Output is correct
6 Correct 18 ms 512 KB Output is correct
7 Incorrect 17 ms 512 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 37 ms 384 KB Output is correct
4 Correct 236 ms 504 KB Output is correct
5 Correct 591 ms 504 KB Output is correct
6 Correct 252 ms 384 KB Output is correct
7 Correct 41 ms 384 KB Output is correct
8 Correct 65 ms 384 KB Output is correct
9 Correct 292 ms 384 KB Output is correct
10 Correct 11 ms 384 KB Output is correct
11 Correct 29 ms 512 KB Output is correct
12 Correct 30 ms 608 KB Output is correct
13 Correct 29 ms 580 KB Output is correct
14 Correct 30 ms 512 KB Output is correct
15 Correct 19 ms 596 KB Output is correct
16 Correct 18 ms 512 KB Output is correct
17 Incorrect 17 ms 512 KB Output isn't correct
18 Halted 0 ms 0 KB -