이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ft first
using namespace std;
using namespace __gnu_pbds;
const int M = 50100;
const int N = 100100;
const int K = 100100;
const int oo = 2e9;
gp_hash_table<int, bool> inside[K];
int f[N];
// проверить, вдруг на большие ограничения залетит
int minimumInstructions(int n, int m, int k, std::vector<int> C,
std::vector<int> A, std::vector<std::vector<int>> B) {
for (int i = 0; i < m; i++)
for (int j = 0; j < A[i]; j++)
inside[B[i][j]][i] = 1;
f[n] = 0;
fill(f, f + n, oo);
for (int i = n - m; i >= 0; i--){
int mn = oo;
for (int j = 1; j <= m; j++)
mn = min(mn, f[i + j]);
if (mn == oo) continue;
for (auto cr : inside[C[i]]){
int now = cr.ft;
bool ok = 1;
for (int it = 1; it < m && ok; it++){
now++;
if (now == m) now = 0;
if (inside[C[i + it]].find(now) == inside[now].end()){
ok = 0;
break;
}
}
if (ok){
f[i] = mn + 1;
break;
}
}
}
return (f[0] == oo ? -1 : f[0]);
}
# | 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... |