Submission #1242108

#TimeUsernameProblemLanguageResultExecution timeMemory
1242108AmirAli_H1축구 경기장 (IOI23_soccer)C++17
25 / 100
225 ms47600 KiB
// In the name of Allah

#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;

typedef		long long int			ll;
typedef		long double				ld;
typedef		pair<int, int>			pii;
typedef		pair<ll, ll>			pll;
typedef		complex<ld>				cld;

#define		all(x)					(x).begin(),(x).end()
#define		len(x)					((ll) (x).size())
#define		F						first
#define		S						second
#define		pb						push_back
#define		sep						' '
#define		endl					'\n'
#define		Mp						make_pair
#define		kill(x)					cout << x << '\n', exit(0)
#define		set_dec(x)				cout << fixed << setprecision(x);
#define		file_io(x,y)			freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 2000 + 4;

int n;
int A[maxn][maxn];
vector<pair<int, pii>> lsx;

int biggest_stadium(int N, vector<vector<int>> F) {
	n = N; int sm = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i][j] = F[i][j];
			if (A[i][j] == 0) sm++;
		}
	}
	int lx = n, rx = -1;
	for (int i = 0; i < n; i++) {
		int jx = 0, tx = 0;
		for (int j = 0; j < n; j++) {
			if (A[i][j] != A[i][jx]) {
				if (A[i][jx] == 0) {
					lsx.pb(Mp(i, Mp(jx, j))); tx++;
					lx = min(lx, i); rx = max(rx, i);
				}
				jx = j;
			}
		}
		if (A[i][jx] == 0) {
			lsx.pb(Mp(i, Mp(jx, n))); tx++;
			lx = min(lx, i); rx = max(rx, i);
		}
		if (tx >= 2) return 0;
	}
	if (rx - lx + 1 != len(lsx)) return 0;
	for (int i = 0; i < len(lsx); i++) {
		int i1 = i - 1, i2 = i + 1;
		int lx = lsx[i].S.F, rx = lsx[i].S.S;
		bool flag = 1;
		for (int j = 0; j < len(lsx) - 1; j++) {
			if (i1 < 0) {
				int l2 = lsx[i2].S.F, r2 = lsx[i2].S.S;
				if (l2 < lx || r2 > rx) {
					flag = 0;
					break;
				}
				lx = l2; rx = r2; i2++;
			}
			else if (i2 >= len(lsx)) {
				int l1 = lsx[i1].S.F, r1 = lsx[i1].S.S;
				if (l1 < lx || r1 > rx) {
					flag = 0;
					break;
				}
				lx = l1; rx = r1; i1--;
			}
			else {
				int l1 = lsx[i1].S.F, r1 = lsx[i1].S.S;
				int l2 = lsx[i2].S.F, r2 = lsx[i2].S.S;
				if (r1 - l1 + 1 >= r2 - l2 + 1) {
					if (l1 < lx || r1 > rx) {
						flag = 0;
						break;
					}
					lx = l1; rx = r1; i1--;
				}
				else {
					if (l2 < lx || r2 > rx) {
						flag = 0;
						break;
					}
					lx = l2; rx = r2; i2++;
				}
			}
		}
		if (flag) return sm;
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...