Submission #1032322

# Submission time Handle Problem Language Result Execution time Memory
1032322 2024-07-23T15:45:51 Z slivajan Painting Walls (APIO20_paint) C++17
12 / 100
22 ms 9116 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long un;
typedef vector<un> vuc;
typedef vector<bool> vol;

#define vec vector
#define REP(i, a, b) for (un i = (un)a; i < (un)b; i++)
#define FEAC(i, a) for (auto&& i : a)

constexpr un INF = 1e9;

int minimumInstructions(int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) {
  
    vuc tab(K, -1);

    REP(m, 0, M) {
      FEAC(col, B[m]) tab[col] = m;
    }

    un ret = 0;
    un x = 0;

    while (x < N)
    {
      un nejkdy = 0;
      REP(y, 0, M){
        bool bad = false;
        bool skoc = false;
        un kdy = M;

        REP(l, 0, M){
          if ((x+l - skoc*M < 0) or (x+l - skoc*M >= N) or (tab[C[x+l - skoc*M]] != (y+l)%M)){
            if (not skoc) {
              kdy = l;
              l--;
              skoc = true;
            }
            else{
              bad = true;
              break;
            }
          }
        }

        if(not bad){
          nejkdy = max(nejkdy, kdy);
        }
      }

      if (nejkdy == 0){
        return -1;
      }

      x += nejkdy;
      ret++;

    }
    
  return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1204 KB Output is correct
17 Correct 1 ms 1120 KB Output is correct
18 Correct 1 ms 1120 KB Output is correct
19 Correct 1 ms 1120 KB Output is correct
20 Correct 1 ms 1376 KB Output is correct
21 Correct 1 ms 1120 KB Output is correct
22 Correct 8 ms 2424 KB Output is correct
23 Correct 7 ms 2396 KB Output is correct
24 Correct 7 ms 2400 KB Output is correct
25 Correct 3 ms 608 KB Output is correct
26 Correct 1 ms 608 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 444 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 3 ms 1904 KB Output is correct
32 Correct 4 ms 1904 KB Output is correct
33 Correct 3 ms 1884 KB Output is correct
34 Correct 4 ms 1884 KB Output is correct
35 Correct 3 ms 1884 KB Output is correct
36 Correct 3 ms 1768 KB Output is correct
37 Correct 9 ms 2924 KB Output is correct
38 Correct 12 ms 2908 KB Output is correct
39 Correct 8 ms 2916 KB Output is correct
40 Correct 5 ms 1112 KB Output is correct
41 Correct 3 ms 1112 KB Output is correct
42 Correct 6 ms 1372 KB Output is correct
43 Correct 4 ms 864 KB Output is correct
44 Correct 5 ms 856 KB Output is correct
45 Correct 5 ms 1288 KB Output is correct
46 Correct 19 ms 8540 KB Output is correct
47 Correct 11 ms 5072 KB Output is correct
48 Correct 14 ms 7516 KB Output is correct
49 Correct 16 ms 6988 KB Output is correct
50 Correct 17 ms 6488 KB Output is correct
51 Correct 16 ms 4700 KB Output is correct
52 Correct 5 ms 1372 KB Output is correct
53 Correct 5 ms 1372 KB Output is correct
54 Correct 8 ms 1372 KB Output is correct
55 Correct 6 ms 1212 KB Output is correct
56 Correct 5 ms 1372 KB Output is correct
57 Correct 5 ms 1372 KB Output is correct
58 Correct 21 ms 9004 KB Output is correct
59 Correct 21 ms 9052 KB Output is correct
60 Correct 22 ms 9052 KB Output is correct
61 Correct 22 ms 9116 KB Output is correct
62 Correct 21 ms 9044 KB Output is correct
63 Correct 21 ms 9016 KB Output is correct
64 Correct 21 ms 8276 KB Output is correct
65 Correct 21 ms 8284 KB Output is correct
66 Correct 21 ms 8120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1204 KB Output is correct
17 Correct 1 ms 1120 KB Output is correct
18 Correct 1 ms 1120 KB Output is correct
19 Correct 1 ms 1120 KB Output is correct
20 Correct 1 ms 1376 KB Output is correct
21 Correct 1 ms 1120 KB Output is correct
22 Incorrect 0 ms 348 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -