Submission #395525

# Submission time Handle Problem Language Result Execution time Memory
395525 2021-04-28T12:51:47 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;
vector<int> a[200000];

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;
	int sz=B.size();
	for(i=0 ; i<sz ; 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:32:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    for(j=0 ; j<a[l].size() ; j++){
      |              ~^~~~~~~~~~~~
/tmp/ccin5izT.o: In function `main':
grader.cpp:(.text.startup+0x27c): undefined reference to `minimumInstructions(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status