답안 #742381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742381 2023-05-16T07:40:46 Z maomao90 Tortoise (CEOI21_tortoise) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h> 
using namespace std;

template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

#ifdef DEBUG
#define debug(args...) printf(args)
#else
#define debug(args...)
#endif

#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 305

int n;
int a[MAXN];
int prv[MAXN], nxt[MAXN];
int dp[MAXN * 2][MAXN][MAXN][2];
int ans;

int main() {
	scanf("%d", &n);
	int tot = 0;
	REP (i, 1, n + 1) {
		scanf("%d", &a[i]);
		if (a[i] != -1) {
			tot += a[i];
		}
	}
	int tmp = -1;
	REP (i, 1, n + 1) {
		if (a[i] == -1) tmp = i;
		if (tmp == -1) {
			prv[i] = -INF;
		} else {
			prv[i] = tmp;
		}
	}
	int tmp = -1;
	RREP (i, n, 1) {
		if (a[i] == -1) tmp = i;
		if (tmp == -1) {
			nxt[i] = INF;
		} else {
			nxt[i] = tmp;
		}
	}
	REP (i, 0, 2 * n + 5) {
		REP (j, 0, n + 5) {
			REP (k, 0, a[i] + 1) {
				REP (l, 0, 2) {
					dp[i][j][k][l] = -INF;
					mx[i][j][l] = -INF;
				}
			}
		}
	}
	REP (i, 1, 2 * n + 5) {
		REP (j, 1, n + 5) {
			REP (k, 0, a[i] + 1) {
				REP (l, 0, 2) {
					dp[i][j][k][l] = mx[i - 1][j - 1][l];
					mxto(mx[i][j][l], dp[i][j][k][l]);
				}
				if (k == 0) continue;
				int time = min((j - prv[j]) * 2 - 1, (nxt[j] - j) * 2 + 1);
				dp[i][j][k][1] = dp[i - 1][j][k - 1][0];
				mxto(dp[i][j][k][1], dp[i - time][j][k - 1][1]);
				time = min(j - prv[j], nxt[j] - j);
				dp[i][j][k][0] = dp[i
				mxto(mx[i][j][l], dp[i][j][k][l]);
			}
		}
	}
				if (k > 0 && k == j && a[j] == 1 && (i + 1) / 2 <= j) {
	printf("%d\n", tot - ans);
	return 0;
}

/*
8
-1 1 0 1 -1 1 1 1
*/

Compilation message

tortoise.cpp: In function 'int main()':
tortoise.cpp:60:6: error: redeclaration of 'int tmp'
   60 |  int tmp = -1;
      |      ^~~
tortoise.cpp:51:6: note: 'int tmp' previously declared here
   51 |  int tmp = -1;
      |      ^~~
tortoise.cpp:74:6: error: 'mx' was not declared in this scope
   74 |      mx[i][j][l] = -INF;
      |      ^~
tortoise.cpp:83:23: error: 'mx' was not declared in this scope
   83 |      dp[i][j][k][l] = mx[i - 1][j - 1][l];
      |                       ^~
tortoise.cpp:91:26: error: expected ']' before 'mxto'
   91 |     dp[i][j][k][0] = dp[i
      |                          ^
      |                          ]
   92 |     mxto(mx[i][j][l], dp[i][j][k][l]);
      |     ~~~~                  
tortoise.cpp:92:5: error: invalid conversion from 'int (*)[305][2]' to 'int' [-fpermissive]
   91 |     dp[i][j][k][0] = dp[i
      |                      ~~~~
   92 |     mxto(mx[i][j][l], dp[i][j][k][l]);
      |     ^~~~
      |     |
      |     int (*)[305][2]
tortoise.cpp:91:26: error: expected ';' before 'mxto'
   91 |     dp[i][j][k][0] = dp[i
      |                          ^
      |                          ;
   92 |     mxto(mx[i][j][l], dp[i][j][k][l]);
      |     ~~~~                  
tortoise.cpp:96:9: error: 'k' was not declared in this scope
   96 |     if (k > 0 && k == j && a[j] == 1 && (i + 1) / 2 <= j) {
      |         ^
tortoise.cpp:96:23: error: 'j' was not declared in this scope
   96 |     if (k > 0 && k == j && a[j] == 1 && (i + 1) / 2 <= j) {
      |                       ^
tortoise.cpp:96:42: error: 'i' was not declared in this scope
   96 |     if (k > 0 && k == j && a[j] == 1 && (i + 1) / 2 <= j) {
      |                                          ^
tortoise.cpp:99:1: error: expected '}' at end of input
   99 | }
      | ^
tortoise.cpp:42:12: note: to match this '{'
   42 | int main() {
      |            ^
tortoise.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
tortoise.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~