Submission #792901

# Submission time Handle Problem Language Result Execution time Memory
792901 2023-07-25T10:44:05 Z Trisanu_Das Painting Walls (APIO20_paint) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
int minimumInstructions(int N, int M, int K, V C, V A, vector<V> B) {
	vector<int> g[K], x(M), y(M), dp(N+1);
	int ans = 0, i = M, j;
	while(--i >= 0) for(int &s : B[i]) g[s].push_back(i);
	for(i = N; --i >= 0; x.swap(y)) {
		if(i+2 < N) for(int s : g[C[i+2]]) x[s] = 0;
		for(int s : g[C[i]])  if((x[s] = 1 + y[(s + 1) % M]) >= M) dp[i] = 1;
	}
	for(dp[N] = dp[i=0]; i < N; i = j, ans++) {
		for(j = min(N, i+M); j > i && !dp[j]; --j);
		if(i == j) return -1;
	}
	return ans;
}

Compilation message

paint.cpp:3:46: error: 'V' has not been declared
    3 | int minimumInstructions(int N, int M, int K, V C, V A, vector<V> B) {
      |                                              ^
paint.cpp:3:51: error: 'V' has not been declared
    3 | int minimumInstructions(int N, int M, int K, V C, V A, vector<V> B) {
      |                                                   ^
paint.cpp:3:63: error: 'V' was not declared in this scope
    3 | int minimumInstructions(int N, int M, int K, V C, V A, vector<V> B) {
      |                                                               ^
paint.cpp:3:64: error: template argument 1 is invalid
    3 | int minimumInstructions(int N, int M, int K, V C, V A, vector<V> B) {
      |                                                                ^
paint.cpp:3:64: error: template argument 2 is invalid
paint.cpp: In function 'int minimumInstructions(int, int, int, int, int, int)':
paint.cpp:6:32: error: invalid types 'int[int]' for array subscript
    6 |  while(--i >= 0) for(int &s : B[i]) g[s].push_back(i);
      |                                ^
paint.cpp:8:30: error: invalid types 'int[int]' for array subscript
    8 |   if(i+2 < N) for(int s : g[C[i+2]]) x[s] = 0;
      |                              ^
paint.cpp:9:18: error: invalid types 'int[int]' for array subscript
    9 |   for(int s : g[C[i]])  if((x[s] = 1 + y[(s + 1) % M]) >= M) dp[i] = 1;
      |                  ^