Submission #974918

#TimeUsernameProblemLanguageResultExecution timeMemory
974918hirayuu_ojPainting Walls (APIO20_paint)C++17
0 / 100
0 ms604 KiB
#include "paint.h" #include <algorithm> #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) #define all(x) x.begin(),x.end(); using ll=long long; int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { vector<vector<int>> cols(K); rep(i,M){ for(int j:B[i]){ cols[j].emplace_back(i); } } int ans=0; int cnt=0; vector<int> can; rep(i,N){ if(!can.empty()){ vector<int> nxt; for(int j:can){ int now=(j+1)%M; if(*lower_bound(B[now].begin(),B[now].end(),C[i])==C[i]){ nxt.emplace_back(now); } } swap(can,nxt); if(can.empty()){ if(ans==0){ return -1; } cnt=0; ans++; can.clear(); } } if(cnt==0){ can=cols[C[i]]; } cnt++; if(cnt==M){ cnt=0; ans++; can.clear(); } } if(cnt!=0)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...