#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |