Submission #965891

#TimeUsernameProblemLanguageResultExecution timeMemory
965891willychanPainting Walls (APIO20_paint)C++17
0 / 100
1 ms348 KiB
#include "paint.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B) { vector<int> ok; for(int i=0;i<=N-M;i++){ for(int j=0;j<M;j++){ bool work=1; for(int k=0;k<M;k++){ int f = lower_bound(B[(j+k)%M].begin(),B[(j+k)%M].end(),C[i+k])-B[(j+k)%M].begin(); work&=(f<A[(j+k)%M] && B[(j+k)%M][f]==C[i+k]); } if(work){ ok.push_back(i); break; } } } if(ok.empty() || ok[0]!=0) return -1; int cur = 0; int ans = 1; while(cur<N-M-1){ int k = upper_bound(ok.begin(),ok.end(),cur+M)-ok.begin(); k--; if(k<0 || ok[k]==cur) return -1; cur = ok[k]; ans++; } return ans; }
#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...