Submission #735388

# Submission time Handle Problem Language Result Execution time Memory
735388 2023-05-04T05:04:25 Z keisuke6 Painting Walls (APIO20_paint) C++14
0 / 100
0 ms 212 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) ok = true;
    ans += (T[i]-T[i-1]-1)/M+1;
  }
  return (ok ? -1 : 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++){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -