Submission #735495

# Submission time Handle Problem Language Result Execution time Memory
735495 2023-05-04T08:18:15 Z keisuke6 Painting Walls (APIO20_paint) C++14
12 / 100
120 ms 12696 KB
#include "paint.h"
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int minimumInstructions(int N, int M, int K, vector<int> C,vector<int> A, vector<vector<int>> B){
  map<int,int> m;// c, p
  vector<int> AA(N);
  for(int i=0;i<M;i++){
    for(int x:B[i]){
      m[x] = i;
    }
  }
  for(int i=0;i<N;i++){
    if(!m.count(C[i])) return -1;
    AA[i] = m[C[i]];
  }
  vector<int> T = {0};
  for(int i=1;i<N;i++){
    if((AA[i-1]+1)%M != AA[i]){
      T.push_back(i);
    }
  }
  T.push_back(N);
  int ans = 0;
  bool ok = false;
  for(int i=1;i<T.size();i++){
    if(T[i]-T[i-1] < M) return -1;
    ans += (T[i]-T[i-1]-1)/M+1;
  }
  return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int i=1;i<T.size();i++){
      |               ~^~~~~~~~~
paint.cpp:26:8: warning: unused variable 'ok' [-Wunused-variable]
   26 |   bool ok = false;
      |        ^~
# 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 296 KB Output is correct
4 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 48 ms 6268 KB Output is correct
23 Correct 42 ms 6288 KB Output is correct
24 Correct 43 ms 6264 KB Output is correct
25 Correct 3 ms 544 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 596 KB Output is correct
28 Correct 3 ms 596 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 18 ms 2004 KB Output is correct
32 Correct 15 ms 1972 KB Output is correct
33 Correct 19 ms 1876 KB Output is correct
34 Correct 16 ms 1876 KB Output is correct
35 Correct 15 ms 2004 KB Output is correct
36 Correct 18 ms 2004 KB Output is correct
37 Correct 55 ms 6980 KB Output is correct
38 Correct 52 ms 6860 KB Output is correct
39 Correct 57 ms 6844 KB Output is correct
40 Correct 8 ms 1464 KB Output is correct
41 Correct 5 ms 1076 KB Output is correct
42 Correct 15 ms 2048 KB Output is correct
43 Correct 8 ms 1492 KB Output is correct
44 Correct 7 ms 1492 KB Output is correct
45 Correct 10 ms 2320 KB Output is correct
46 Correct 95 ms 11516 KB Output is correct
47 Correct 58 ms 6816 KB Output is correct
48 Correct 59 ms 9416 KB Output is correct
49 Correct 90 ms 10544 KB Output is correct
50 Correct 85 ms 10400 KB Output is correct
51 Correct 66 ms 7888 KB Output is correct
52 Correct 8 ms 1664 KB Output is correct
53 Correct 8 ms 1592 KB Output is correct
54 Correct 11 ms 2004 KB Output is correct
55 Correct 11 ms 2188 KB Output is correct
56 Correct 11 ms 2256 KB Output is correct
57 Correct 11 ms 2240 KB Output is correct
58 Correct 116 ms 12576 KB Output is correct
59 Correct 99 ms 12556 KB Output is correct
60 Correct 93 ms 12608 KB Output is correct
61 Correct 114 ms 12484 KB Output is correct
62 Correct 118 ms 12696 KB Output is correct
63 Correct 109 ms 12468 KB Output is correct
64 Correct 99 ms 12428 KB Output is correct
65 Correct 120 ms 12308 KB Output is correct
66 Correct 107 ms 12360 KB Output is correct
# 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 296 KB Output is correct
4 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Incorrect 1 ms 212 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -