답안 #1089064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089064 2024-09-15T21:41:28 Z DeathIsAwe Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
컴파일 오류
0 ms 0 KB
    #include <bits/stdc++.h>
    using namespace std;
    #define minim(X, Y) (X = min(X, Y))
    #define F(X, Y) for(int X = 0; X < Y; X++)
    #define g(X) (X ? (X > 1 ? z : y) : x)
     
    int Z = 202, INF = 1e9;
     
    int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z;
     
    int main() {
    	cin >> N, getchar();
    	F(i, N) {
    		char v = getchar();
    		A[i] = (v < 82) + (v < 89);
    	}
     
    	F(i, Z) F(j, Z) F(k, Z) F(l, 3)
    		DP[i][j][k][l] = (i || j || k) ? INF : 0;
     
    	F(i, N) {
    		if(++c[A[i]] >= Z-1) break;
    		p[A[i]][g(A[i]) = c[A[i]]] = i;
    		F(j, 3) h[j][i] = c[j];
     
    		F(j, i+1) F(k, i+1) F(o, 3) {
    			(A[i] ? x : y) = j;
    			(A[i] < 2 ? z : y) = k;
    			if(x > c[0] || y > c[1] || z > c[2]) continue;
    			int &w = g(o), a = INF, b = 0;
    			if(!w) continue; --w;
    			F(r, 3) minim(a, r != o ? DP[x][y][z][r] : INF); ++w;
    			F(r, 3) b += r != o ? max(0, g(r) - h[r][p[o][w]]) : 0;
    			minim(DP[x][y][z][o], a + b);
    		}
    	}
    	int res = INF;
    	F(i, 3) minim(res, DP[c[0]][c[1]][c[2]][i]);
     
    	cout << (res == INF ? -1 : res);
    }

Compilation message

joi2019_ho_t3.cpp:9:17: error: array bound is not an integer constant before ']' token
    9 |     int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z;
      |                 ^
joi2019_ho_t3.cpp:9:24: error: array bound is not an integer constant before ']' token
    9 |     int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z;
      |                        ^
joi2019_ho_t3.cpp:9:27: error: array bound is not an integer constant before ']' token
    9 |     int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z;
      |                           ^
joi2019_ho_t3.cpp:9:30: error: array bound is not an integer constant before ']' token
    9 |     int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z;
      |                              ^
joi2019_ho_t3.cpp:9:44: error: array bound is not an integer constant before ']' token
    9 |     int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z;
      |                                            ^
joi2019_ho_t3.cpp:9:55: error: array bound is not an integer constant before ']' token
    9 |     int N, A[Z*2], DP[Z][Z][Z][3], p[3][Z*2], h[3][Z*2], c[3], x, y, z;
      |                                                       ^
joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:15:7: error: 'A' was not declared in this scope
   15 |       A[i] = (v < 82) + (v < 89);
      |       ^
joi2019_ho_t3.cpp:19:7: error: 'DP' was not declared in this scope
   19 |       DP[i][j][k][l] = (i || j || k) ? INF : 0;
      |       ^~
joi2019_ho_t3.cpp:22:14: error: 'A' was not declared in this scope
   22 |       if(++c[A[i]] >= Z-1) break;
      |              ^
joi2019_ho_t3.cpp:23:7: error: 'p' was not declared in this scope
   23 |       p[A[i]][g(A[i]) = c[A[i]]] = i;
      |       ^
joi2019_ho_t3.cpp:23:9: error: 'A' was not declared in this scope
   23 |       p[A[i]][g(A[i]) = c[A[i]]] = i;
      |         ^
joi2019_ho_t3.cpp:24:15: error: 'h' was not declared in this scope
   24 |       F(j, 3) h[j][i] = c[j];
      |               ^
joi2019_ho_t3.cpp:31:8: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |        if(!w) continue; --w;
      |        ^~
joi2019_ho_t3.cpp:31:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |        if(!w) continue; --w;
      |                         ^~
joi2019_ho_t3.cpp:32:34: error: 'DP' was not declared in this scope
   32 |        F(r, 3) minim(a, r != o ? DP[x][y][z][r] : INF); ++w;
      |                                  ^~
joi2019_ho_t3.cpp:3:37: note: in definition of macro 'minim'
    3 |     #define minim(X, Y) (X = min(X, Y))
      |                                     ^
joi2019_ho_t3.cpp:33:44: error: 'h' was not declared in this scope
   33 |        F(r, 3) b += r != o ? max(0, g(r) - h[r][p[o][w]]) : 0;
      |                                            ^
joi2019_ho_t3.cpp:34:14: error: 'DP' was not declared in this scope
   34 |        minim(DP[x][y][z][o], a + b);
      |              ^~
joi2019_ho_t3.cpp:3:26: note: in definition of macro 'minim'
    3 |     #define minim(X, Y) (X = min(X, Y))
      |                          ^
joi2019_ho_t3.cpp:38:25: error: 'DP' was not declared in this scope
   38 |      F(i, 3) minim(res, DP[c[0]][c[1]][c[2]][i]);
      |                         ^~
joi2019_ho_t3.cpp:3:37: note: in definition of macro 'minim'
    3 |     #define minim(X, Y) (X = min(X, Y))
      |                                     ^