Submission #949373

# Submission time Handle Problem Language Result Execution time Memory
949373 2024-03-19T07:24:40 Z vjudge1 Painting Walls (APIO20_paint) C++17
0 / 100
1 ms 348 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

template<class S, class T> bool chmin(S& a, const T& b) {
  return a > b ? (a = b) == b : false;
}
template<class S, class T> bool chmax(S& a, const T& b) {
  return a < b ? (a = b) == b : false;
}
const int inf = 1e9;

int minimumInstructions(int n, int m, int K, 
  vector<int> c, vector<int> a, vector<vector<int>> b) {
  vector<int> dp(n, inf);
  vector<unordered_map<int, bool>> mp(m);
  for (int i = 0; i < m; ++i) {
    for (auto x : b[i]) {
      mp[i][x] = true;
    }
  }
  for (int i = 0; i + m - 1 < n; ++i) {
    for (int k = 0; k < m; ++k) {
      int r = i;
      bool flag = true;
      for (int j = k; j < m; ++j) {
        if (!mp[j][c[r]]) {
          flag = false;
          break;
        }
        r++;
      }
      if (flag) {
        for (int j = 0; j < k; ++j) {
          if (!mp[j][c[r]]) break;
          r++;
        }
      }
      for (int j = i; j < r; ++j) {
        if (i) chmin(dp[j], dp[i - 1] + 1);
        else chmin(dp[j], 1);
      }
    }
  }
  return dp[n - 1] == inf ? -1 : dp[n - 1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -