Submission #410348

#TimeUsernameProblemLanguageResultExecution timeMemory
410348Carmel_Ab1Painting Walls (APIO20_paint)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #include "paint.h" //#include "grader.cpp" using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; #define all(x) x.begin(),x.end() #define pb push_back #define umap unordered_map int minimumInstructions(int N, int M, int K, vi C,vi A, vvi B) { for(int i=0; i<B.size(); i++) sort(all(B[i])); umap<int,umap<int,int>> can;// iff a sequence from j can start in i for(int j=0; j<M; j++){ can[N-M][j]=0; for(int j2=0; j2<M;can[N-M][j]++,j2++) if(!binary_search(all(B[(j+j2)%M]),C[(N-M+j2)])) break; } set<int>segs; for(int i=N-M-1; 0<=i;i--){ for(int j=0; j<M; j++){ if(!binary_search(all(B[j]),C[i]))continue; can[i][j]=min(M,can[i+1][(j+1)%M]+1); if(can[i][j]==M) segs.insert(i); break; } } int ans=0; vector<bool>cov(N); for(int i=0; i<N;i++){ if(cov[i])continue; int l=-1; for(int j=0;i-j>=0 && j<M; j++) if(segs.count(i-j)) { l = i - j; break; } if(l==-1)return -1; for(int j=l; j<l+M; j++) cov[j]=1; ans++; } return ans; }

Compilation message (stderr)

paint.cpp: In function 'int minimumInstructions(int, int, int, vi, vi, vvi)':
paint.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0; i<B.size(); i++)
      |                  ~^~~~~~~~~
#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...