| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 396479 | Kevin_Zhang_TW | 벽 칠하기 (APIO20_paint) | C++17 | 1 ms | 204 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 <bits/stdc++.h>
#include "paint.h"
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
const int inf = 1e9 + 7;
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)
sort(AI(B[i]));
vector<int> ok;
for (int i = 0;i <= N-M;++i) {
auto valid = [&](int i, int j) {
for (int k = 0;k < M;++k) {
if (!binary_search(AI(B[(j+k)%M]), C[i+k]))
return false;
}
return true;
};
for (int j = 0;j < M;++j)
if (valid(i, j)) {
ok.pb(i);
break;
}
}
// good is the max index I can take
int res = 0, good = 0, bst = -1;
ok.pb(N);
for (int id : ok) {
DE(res, good, bst, id);
if (id > good) {
if (bst == -1) return -1;
++res;
good = bst + M;
bst = -1;
}
if (id <= good) chmax(bst, id);
}
return res;
}
Compilation message (stderr)
| # | 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... | ||||
