Submission #955210

# Submission time Handle Problem Language Result Execution time Memory
955210 2024-03-29T16:47:14 Z 42kangaroo Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include "soccer.h"
#include "bits/stdc++.h"


int biggest_stadium(int N, std::vector<std::vector<int>> F) {
	using namespace std;
	using dp_t = vector<vector<vector<vector<int>>>>;
	bool allPos = true;
	int su = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			su += F[i][j];
		}
	}
	if (su == 1) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (F[i][j] == 1) {
					return N*N - min(i + 1, N - i)*min(j + 1, N - j);
				}
			}
		}
	} else {
		vector<pair<int, int>> ra(N);
		vector<int> les(N);
		for (int i = 0; i < N; ++i) {
			ra[i].first = 0;
			for (; ra[i].first < N; ra[i].first++) {
				if (F[i][ra[i].first] == 0) break;
			}
			ra[i].second = N - 1;
			for (; ra[i].second >= 0; ra[i].second--) {
				if (F[i][ra[i].second] == 0) break;
			}
			les[i] = ra[i].second - ra[i].first + 1;
			for (int j = ra[i].first; j <= ra[i].second; ++j) {
				if (F[i][j] == 1) allPos = false;
			}
			if (!allPos) break;
		}
		int tot = 0;
		int maI = max_element(les.begin(), les.end()) - les.begin();
		pair<int, int> actRa = ra[maI];
		pair<int, int> oRa = {maI, maI};
		tot = les[maI];
		while (allPos && oRa != make_pair(0, N - 1)) {
			int ne = oRa.first - 1;
			if (ne < 0 || (oRa.second < N - 1 && les[ne] < les[oRa.second + 1])) ne = oRa.second + 1;
			if (les[ne] < 0) break;
			if (actRa.first > ra[ne].first || actRa.second < ra[ne].second) allPos = false;
			actRa = ra[ne];
			tot += les[ne];
			oRa = {min(oRa.first, ne), max(oRa.second, ne)};
		}
		if (allPos) return tot;
		else if (N > 50) return 0;
		else {
			vector<vector<int>> prefS(N, vector<int>(N + 1, 0));
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					prefS[i][j + 1] = prefS[i][j] + F[i][j];
				}
			}
			dp_t dp(N, vector<vector<vector<int>>>(N, vector<vector<int>>(N, vector<int>(N, -N * N))));
			int ma = 0;
			for (int i = N - 1; i >= 0; --i) {
				for (int j = i; j < N; ++j) {
					for (int k = 0; k < N; ++k) {
						for (int l = N - 1; l >= k; --l) {
							if (l < N - 1) dp[i][j][k][l] = dp[i][j][k][l + 1];
							if (k > 0) dp[i][j][k][l] = max(dp[i][j][k][l], dp[i][j][k - 1][l]);
							if (i == j) {
								if (prefS[i][l + 1] - prefS[i][k] == 0) dp[i][j][k][l] = max(dp[i][j][k][l], l - k + 1);
							} else {
								if (prefS[i][l + 1] - prefS[i][k] == 0) dp[i][j][k][l] = max(dp[i][j][k][l], l - k + 1 +
								                                                                             dp[i +
								                                                                                1][j][k][l]);
								if (prefS[j][l + 1] - prefS[j][k] == 0) dp[i][j][k][l] = max(dp[i][j][k][l], l - k + 1 +
								                                                                             dp[i][j -
								                                                                                   1][k][l]);
							}
							ma = max(ma, dp[i][j][k][l]);
						}
					}
				}
			}
			return ma;
		}
	}
}

Compilation message

closing.cpp:1:10: fatal error: soccer.h: No such file or directory
    1 | #include "soccer.h"
      |          ^~~~~~~~~~
compilation terminated.