Submission #866157

# Submission time Handle Problem Language Result Execution time Memory
866157 2023-10-25T13:35:49 Z vjudge1 Soccer Stadium (IOI23_soccer) C++17
0 / 100
0 ms 600 KB
#include "soccer.h"
using namespace std;
int biggest_stadium(int n, vector<vector<int>> f)
{
	vector<vector<int>> a(n+2, vector<int>(n+2, 1));
	vector<vector<int>> u(n+2, vector<int>(n+2, 0));// how many empty up
	vector<vector<int>> l(n+2, vector<int>(n+2, 0));// left
	vector<vector<int>> r(n+2, vector<int>(n+2, 0));// right
	vector<vector<int>> d(n+2, vector<int>(n+2, 0));// down
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			a[i+1][j+1] = f[i][j];
		}
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (a[i][j]) continue;
			l[i][j] = l[i][j - 1] + 1;
			u[i][j] = u[i - 1][j] + 1;
		}
	}
	for (int i = n; i >= 1; i--){
		for (int j = n; j >= 1; j--){
			if (a[i][j]) continue;
			r[i][j] = r[i][j + 1] + 1;
			d[i][j] = d[i + 1][j] + 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (a[i][j]) continue;
			int siz = 0;
			int up = u[i][j];
			int dw = d[i][j];
			vector<int> mu(n+2);
			vector<int> md(n+2);
			for (int k = j; k < j + r[i][j]; k++){
				up = min(up, u[i][k]);
				dw = min(dw, d[i][k]);
				mu[k] = up;
				md[k] = dw;
			}
			for (int k = j-1; k > j - l[i][j]; k--){
				up = min(up, u[i][k]);
				dw = min(dw, d[i][k]);
				mu[k] = up;
				md[k] = dw;
			}
			for (int k = j, cc = 0; k < j + r[i][j]; k++, cc++){
				int utm = u[i][k];
				if(k-cc >= 1) utm = min(u[i][k], mu[j-cc]);
				int dtm = d[i][k];
				if(k-cc >= 1) dtm = min(d[i][k], md[j-cc]);
				up = min(up, utm);
				dw = min(dw, dtm);
				siz += up + dw - 1;
			}
			up = u[i][j];
			dw = d[i][j];
			for (int k = j, cc = 0; k > j - l[i][j]; k--, cc++){
				int utm = u[i][k];
				if(k+cc <= n) utm = min(u[i][k], mu[j+cc]);
				int dtm = d[i][k];
				if(k+cc <= n) dtm = min(d[i][k], md[j+cc]);
				up = min(up, utm);
				dw = min(dw, dtm);
				siz += up + dw - 1;
			}
			ans = max(ans, siz - u[i][j] - d[i][j] + 1);
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 600 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 600 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 600 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 600 KB wrong
3 Halted 0 ms 0 KB -