# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
566989 | Belgutei | Painting Walls (APIO20_paint) | C++17 | 80 ms | 12560 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 ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define X real()
#define Y imag()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MOD1 1000000009
#define sqr(x) sqr((x)*(x))
map<int,bool> mp[1000];
int dp[1005];
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 < B.size(); i ++) {
for(int j = 0; j < B[i].size(); j ++) {
mp[i][B[i][j]] = 1;
}
}
for(int i = M - 1; i < N; i ++) {
int l = i - M + 1;
int r = i;
int starter = 0;
bool check = 0;
while(starter < M) {
int cur = starter;
bool ok = 0;
for(int j = l; j <= r; j ++) {
if(mp[cur][C[j]] == 0) {
ok = 1;
break;
}
cur ++;
if(cur == M) cur = 0;
}
if(ok == 0) {
check = 1;
break;
}
starter ++;
}
if(check == 0) {
continue;
}
if(i == M - 1) {
dp[i] = 1;
continue;
}
int mn = 1e9;
for(int j = i - 1; j >= i - M; j --) {
if(dp[j] == 0) continue;
mn = min(mn,dp[j]);
}
if(mn != 1e9) {
mn ++;
dp[i] = mn;
}
}
if(dp[N - 1] == 0) return -1;
return dp[N - 1];
}
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... |