Submission #981784

# Submission time Handle Problem Language Result Execution time Memory
981784 2024-05-13T14:53:49 Z Abito Painting Walls (APIO20_paint) C++17
Compilation error
0 ms 0 KB
#include "paint.h"
#include <bits/stdc++.h>
#define pb push_back
#define ep insert
using namespace std;
int minimumInstructions(
    int n, int m, int k, vector<int> C,
    vector<int> A, vector<vector<int>> B){
    int D[k],R[n];
    for (int i=0;i<n;i++) R[i]=0;
    for (int i=0;i<k;i++) D[i]=-1;
    for (int i=0;i<m;i++) for (auto u:B[i]) D[u]=i;
    for (int i=0;i<k;i++) if (D[i]==-1) return -1;
    for (int i=0;i<n;i++){
        int r=i;
        for (int j=0;j<n-i;j++){
            if (D[c[i]+j]==(D[c[i+j]])%m) r=j+i;
            else break;
        }
        for (int j=i;j<=r;j++) R[j]=r;
        i=r;
    }
    int ans=0;
    for (int i=0;i<n;i++){
        if (R[i]-i<m-1) return -1;
        int len=R[i]-i+1;
        ans+=len/m+bool(len%m);
        i=R[i];
    }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:17:19: error: 'c' was not declared in this scope
   17 |             if (D[c[i]+j]==(D[c[i+j]])%m) r=j+i;
      |                   ^