이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |