Submission #717160

# Submission time Handle Problem Language Result Execution time Memory
717160 2023-04-01T10:04:49 Z LittleCube Painting Walls (APIO20_paint) C++14
0 / 100
1500 ms 1648 KB
#include "paint.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;

int minimumInstructions(
    int N, int M, int K, vector<int> C,
    vector<int> A, vector<vector<int>> B)
{

  auto match = [&](int i, int j)
  {
    auto iter = lower_bound(B[j].begin(), B[j].end(), C[i]);
    if(iter != B[j].end() && *iter == C[i])
        return 1;
    return 0;
  };
  vector<int> cover(N, 0), dp(N, 0);
  for (int x = 0; x < M; x++)
  {
    int cnt = 0;
    for (int y = 0; y < M; y++)
      cnt += match(y, (x + y) % M);
    for (int y = 0; y < N - M; y++)
    {
      cover[y] |= (cnt == M);
      cnt -= match(y, (x + y) % M);
      cnt += match(y + M, (x + y + M) % M);
    }
    cover[N - M] |= (cnt == M);
  }
  for (int i = 0; i < N; i++)
  {
    dp[i] = (cover[i] ? i : (i ? dp[i - 1] : 0));
  }
  int cur = 0, ans = 0;
  for (int i = 0; i < N; i++)
    if (cur < N)
      cur = max(cur, dp[cur] + M), ans++;
  return (cur < N ? -1 : ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 4 ms 212 KB Output is correct
14 Correct 3 ms 304 KB Output is correct
15 Correct 4 ms 304 KB Output is correct
16 Correct 3 ms 300 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 300 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 5 ms 336 KB Output is correct
21 Correct 5 ms 304 KB Output is correct
22 Correct 21 ms 1596 KB Output is correct
23 Correct 19 ms 1648 KB Output is correct
24 Correct 20 ms 1596 KB Output is correct
25 Correct 3 ms 568 KB Output is correct
26 Correct 2 ms 596 KB Output is correct
27 Correct 3 ms 596 KB Output is correct
28 Correct 3 ms 564 KB Output is correct
29 Correct 4 ms 596 KB Output is correct
30 Correct 4 ms 596 KB Output is correct
31 Execution timed out 1576 ms 1108 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 4 ms 212 KB Output is correct
14 Correct 3 ms 304 KB Output is correct
15 Correct 4 ms 304 KB Output is correct
16 Correct 3 ms 300 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 300 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 5 ms 336 KB Output is correct
21 Correct 5 ms 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Incorrect 1 ms 296 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 3 ms 304 KB Output is correct
17 Correct 4 ms 304 KB Output is correct
18 Correct 3 ms 300 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 300 KB Output is correct
21 Correct 5 ms 340 KB Output is correct
22 Correct 5 ms 336 KB Output is correct
23 Correct 5 ms 304 KB Output is correct
24 Correct 21 ms 1596 KB Output is correct
25 Correct 19 ms 1648 KB Output is correct
26 Correct 20 ms 1596 KB Output is correct
27 Correct 1 ms 300 KB Output is correct
28 Incorrect 1 ms 296 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 3 ms 304 KB Output is correct
17 Correct 4 ms 304 KB Output is correct
18 Correct 3 ms 300 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 300 KB Output is correct
21 Correct 5 ms 340 KB Output is correct
22 Correct 5 ms 336 KB Output is correct
23 Correct 5 ms 304 KB Output is correct
24 Correct 21 ms 1596 KB Output is correct
25 Correct 19 ms 1648 KB Output is correct
26 Correct 20 ms 1596 KB Output is correct
27 Correct 3 ms 568 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 3 ms 564 KB Output is correct
31 Correct 4 ms 596 KB Output is correct
32 Correct 4 ms 596 KB Output is correct
33 Execution timed out 1576 ms 1108 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 3 ms 304 KB Output is correct
17 Correct 4 ms 304 KB Output is correct
18 Correct 3 ms 300 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 300 KB Output is correct
21 Correct 5 ms 340 KB Output is correct
22 Correct 5 ms 336 KB Output is correct
23 Correct 5 ms 304 KB Output is correct
24 Correct 21 ms 1596 KB Output is correct
25 Correct 19 ms 1648 KB Output is correct
26 Correct 20 ms 1596 KB Output is correct
27 Correct 3 ms 568 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 3 ms 564 KB Output is correct
31 Correct 4 ms 596 KB Output is correct
32 Correct 4 ms 596 KB Output is correct
33 Execution timed out 1576 ms 1108 KB Time limit exceeded
34 Halted 0 ms 0 KB -