Submission #409851

# Submission time Handle Problem Language Result Execution time Memory
409851 2021-05-21T16:36:38 Z Ahmadsm2005 Painting Walls (APIO20_paint) C++14
0 / 100
2 ms 2636 KB
#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:;
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[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(MAXER<N)
COST++;
return COST;
}

Compilation message

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:43:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 | 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 time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Incorrect 2 ms 2636 KB Output isn't correct
4 Halted 0 ms 0 KB -