Submission #409858

#TimeUsernameProblemLanguageResultExecution timeMemory
409858Ahmadsm2005Painting Walls (APIO20_paint)C++14
28 / 100
1577 ms12088 KiB
#include "paint.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; set<int>lolz[50001]; int minimumInstructions(int N,int M,int K,vector<int>C,vector<int>A,vector<vector<int>>B){ for(int i=0;i<B.size();i++){ for(int l=0;l<B[i].size();l++) lolz[i].insert(B[i][l]); } vector<int>P; int CUR=0,COST=0,LAST=-1; for(int i=0;i<N-M+1;i++){ if(LAST==-1){ for(int l=0;l<M;l++){ for(int x=l;x<M+l;x++){ if(lolz[x%M].find(C[x-l+i])==lolz[x%M].end()) goto a; } P.push_back(i); LAST=l; goto b; a:; } //return -1; b:; LAST=-1; continue; } /*LAST=(LAST+1)%M; for(int l=LAST;l<M+LAST;l++){ if(lolz[l%M].find(C[l-LAST+i])==lolz[l%M].end()) goto c; } P.push_back(i); continue; c:;*/ LAST=-1; } if(!P.size()) return -1; if(P[0]!=0) return -1; int MAXER=M; COST=1; for(int i=1;i<P.size();i++){ if(P[i]>MAXER){ if(MAXER==P[i-1]+M) return -1; MAXER=P[i-1]+M; COST++; i--; } } if(P[P.size()-1]+M!=MAXER){ MAXER=P[P.size()-1]+M,COST++; } if(MAXER<N) return -1; return COST; }

Compilation message (stderr)

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:7:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | for(int i=0;i<B.size();i++){
      |             ~^~~~~~~~~
paint.cpp:8:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | for(int l=0;l<B[i].size();l++)
      |             ~^~~~~~~~~~~~
paint.cpp:46:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 | for(int i=1;i<P.size();i++){
      |             ~^~~~~~~~~
paint.cpp:12:5: warning: unused variable 'CUR' [-Wunused-variable]
   12 | int CUR=0,COST=0,LAST=-1;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...