답안 #985127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985127 2024-05-17T11:00:41 Z nnin 벽 칠하기 (APIO20_paint) C++14
컴파일 오류
0 ms 0 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
 
vector<int> f[100005];
 
int seg[200005];
void update(int i, int l, int r, int x, int val) {
  if(l==r) {
    seg[i] += val;
    return;
  }
  int m = (l+r)/2;
  if(x<=m) update(i*2+1, l, m, x, val);
  else update(i*2+2, m+1, r, x, val);
  seg[i] = max(seg[i*2+1], seg[i*2+2]);
}
 
int dp[100005];
 
int minimumInstructions(int N, int M, int K, std::vector<int> C, vector<int> A, vector<vector<int>> B) {
  for(int i=0;i<M;i++) {
    for(int k:B[i]) f[k].push_back(i);
  }
  for(int i=0;i<M;i++) {
    for(int p:f[C[i]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, 1);
    dp[i] = 1;
  }
  if(seg[0]<M) return -1;
  int last = M-1;
  for(int i=M;i<N;i++) {
    if(last<i-M) return -1;
    if(C[i]!=C[i-M]){for(int p:f[C[i-M]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, -1);
    for(int p:f[C[i]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, 1);}
    if(seg[0]==M) {
      for(int j=last+1;j<=i;j++) dp[j] = (i-M>=0 ? dp[i-M]+1 : 1);
      last = i;
    }
  }
  if(last!=N-1) return -1;
  return dp[N-1];
}

Compilation message

paint.cpp:33:2: error: extended character   is not valid in an identifier
   33 |     if(C[i]!=C[i-M]){for(int p:f[C[i-M]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, -1);
      |  ^
paint.cpp:33:5: error: extended character   is not valid in an identifier
   33 |     if(C[i]!=C[i-M]){for(int p:f[C[i-M]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, -1);
      |    ^
paint.cpp:34:2: error: extended character   is not valid in an identifier
   34 |     for(int p:f[C[i]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, 1);}
      |  ^
paint.cpp:34:5: error: extended character   is not valid in an identifier
   34 |     for(int p:f[C[i]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, 1);}
      |    ^
paint.cpp:35:2: error: extended character   is not valid in an identifier
   35 |     if(seg[0]==M) {
      |  ^
paint.cpp:35:5: error: extended character   is not valid in an identifier
   35 |     if(seg[0]==M) {
      |    ^
paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:33:2: error: '\U000000a0' was not declared in this scope
   33 |     if(C[i]!=C[i-M]){for(int p:f[C[i-M]]) update(0, 0, (int)5e4, (p-(i%M)+M)%M, -1);
      |  ^
paint.cpp:35:4: error: expected ';' before '\U000000a0if'
   35 |     if(seg[0]==M) {
      |   ^~~~
      |   ;