This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "paint.h"
#include <vector>
#include <cstdio>
#include <cstring>
#define PB push_back
using namespace std;
typedef vector < int > vi;
const int N = 1e5 + 500;
const int INF = 0x3f3f3f3f;
int naz[N], cookie = 0, lst[N], sad[N], kol[N];
vi tko[N];
int minimumInstructions(int n, int m, int k, vi C, vi A, vector< vi > B) {
for(int i = 0;i < m;i++)
for(int x : B[i])
tko[x].PB(i);
memset(lst, -1, sizeof(lst));
for(int i = 0;i < n;i++){
int dob = 0;
for(int x : tko[C[i]]){
int koj = ((x - i + m) % m + m) % m;
if(lst[koj] != i - 1)
kol[koj] = 0;
lst[koj] = i; kol[koj]++;
// printf("kol[ %d ] = %d\n", koj, kol[koj]);
dob |= (kol[koj] >= m);
}
if(dob){
naz[i - m + 1] = 1;
}
}
int cur = 0, ans = 0, lst = 0, dsn = 0;
for(;cur < n;){
for(;lst <= cur;lst++)
if(naz[lst])
dsn = max(dsn, lst + m);
//printf("cur = %d dsn = %d lst = %d\n", cur, dsn, lst);
if(dsn <= cur)
return -1;
cur = dsn; 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... |