Submission #395522

# Submission time Handle Problem Language Result Execution time Memory
395522 2021-04-28T12:49:15 Z ankhbayar06 Painting Walls (APIO20_paint) C++14
Compilation error
0 ms 0 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define mk make_pair

ll l,i,j,n,m,k,x,o[2000000],b[2000000],c[2000000],s,ans;

int minimumInstructions (int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<int> B){
	n=N;
	m=M;
	k=K;
	l=0;
	for(i=0 ; i<B.size() ; i++){
		if(A[l]>0){
			a[l].pb(b[i]);
			A[l]--;
		}
		else{
			l++;
		}
	}
	for(i=0 ; i<n ; i++){
		b[i]=1;
		for(l=0 ; l<m ; l++){
			k=1;
			for(j=0 ; j<a[l].size() ; j++){
				if(a[l][j]==C[(i+l)%n])k=0;
			}
			if(k==1)b[i]=0;
		}
	}
	l=0;
	for(i=0 ; i<n ; i++){
		if(b[i]==0)l++;
		else{
			s=max(s,l);
			l=0;
		}
	}
	s=max(s,l);
	if(s>=m){
		return -1;
	}
	else{
		ans=0;
		l=0;
		for(i=0 ; i<n ; i+=0){
			if(b[i]==1)l=i;
			o[i]=l;
		}
		for(i=0 ; i<n ; i++){
			ans++;
			x=o[i];
			if(x+M-1<=i)return -1;
			i=x+m-1;
		}
		return ans;
	}
}


Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
paint.cpp:17:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(i=0 ; i<B.size() ; i++){
      |            ~^~~~~~~~~
paint.cpp:19:4: error: 'a' was not declared in this scope
   19 |    a[l].pb(b[i]);
      |    ^
paint.cpp:30:16: error: 'a' was not declared in this scope
   30 |    for(j=0 ; j<a[l].size() ; j++){
      |                ^