# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
597274 | Ozy | Painting Walls (APIO20_paint) | C++17 | 0 ms | 0 KiB |
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<bits/stdc++.h>
using namespace std;
#define lli int
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 20000
lli a,ini;
int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B) {
n = N;
m = M;
k = K;
a = -1;
rep(i,0,m-1) {
if (B[i][0] == C[0]) {
a = i;
break;
}
}
if (a == -1) return -1;
ini = a;
lli res = 0;
rep(i,0,n-1) {
if (C[i] != B[a][0]) return -1;
if (a == ini) res++;
a++;
a %= m;
}
return res;
}