제출 #735376

#제출 시각아이디문제언어결과실행 시간메모리
735376keisuke6Painting Walls (APIO20_paint)C++14
컴파일 에러
0 ms0 KiB
#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> A(N);
  for(int i=0;i<M;i++){
    for(int x:B[i]){
      m[x] = i;
    }
  }
  for(int i=0;i<N;i++) A[i] = m[C[i]];
  int ans = 1;
  for(int i=1;i<N;i++){
    if((A[i-1]+1)%M != A[i]){
      ans++;
      if(N-M < i) return -1;
    } 
  }
  return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:8:15: error: declaration of 'std::vector<int> A' shadows a parameter
    8 |   vector<int> A(N);
      |               ^
paint.cpp:6:72: note: 'std::vector<int> A' previously declared here
    6 | int minimumInstructions(int N, int M, int K, vector<int> C,vector<int> A, vector<vector<int>> B){
      |                                                            ~~~~~~~~~~~~^