제출 #403633

#제출 시각아이디문제언어결과실행 시간메모리
403633Waratpp123벽 칠하기 (APIO20_paint)C++14
0 / 100
2 ms3020 KiB
#include "paint.h" #include <vector> #include<bits/stdc++.h> using namespace std; unordered_map<int,int> mp[50010]; int mark[50010]; int minimumInstructions( int n, int m, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { int i,j,cnt=0,k,ch,err; for(i=0;i<m;i++){ for(auto x : B[i]){ mp[i][x]=1; } } for(i=0;i<=n-m;i++){ ch=0; for(j=0;j<m;j++){ err=0; for(k=0;k<m;k++){ if(mp[(j+k)%m][C[i+k]]==0){ err=1; break; } } if(err==0){ ch=1; break; } } mark[i]=ch; } i=0; cnt=0; int ans=0; while(i<n){ cnt++; if(mark[i]==1){ i+=m; ans++; }else i--; if(cnt==n) break; } if(cnt==n) return -1; return ans; } /* 8 3 5 3 3 1 3 4 4 2 2 3 0 1 2 2 2 3 2 3 4 */
#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...