Submission #1064113

# Submission time Handle Problem Language Result Execution time Memory
1064113 2024-08-18T09:22:18 Z AmirAli_H1 Soccer Stadium (IOI23_soccer) C++17
6 / 100
197 ms 47404 KB
// In the name of Allah

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

typedef			long long				ll;
typedef			pair<int, int>			pii;
typedef			pair<ll, ll>			pll;

#define			F						first
#define			S						second
#define			endl					'\n'
#define			sep						' '
#define			pb						push_back
#define			Mp						make_pair
#define			all(x)					(x).begin(),(x).end()
#define			len(x)					((ll) (x).size())

const int maxn = 2000 + 4;

int n;
int A[maxn][maxn];
vector<pii> ls;

bool cmp(pii i, pii j) {
	return ((i.S - i.F) > (j.S - j.F));
}

bool is_ok() {
	ls.clear();
	for (int i = 0; i < n; i++) {
		int x = 0;
		for (int j = 0; j < n; j++) {
			if (A[i][j] != A[i][x]) {
				if (A[i][x] == 0) ls.pb(Mp(x, j - 1));
				x = j;
			}
		}
	}
	sort(all(ls), cmp);
	
	for (int i = 1; i < len(ls); i++) {
		if (ls[i].F < ls[i - 1].F || ls[i].S > ls[i - 1].S) return 0;
	}
	return 1;
}

int check() {
	int num = 0; 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) num += (A[i][j] == 0);
	}
	
	bool ok = 1;
	ok &= is_ok();
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) swap(A[i][j], A[j][i]);
	}
	ok &= is_ok();
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) swap(A[i][j], A[j][i]);
	}
	if (ok) return num;
	else return 0;
}

int biggest_stadium(int N, vector<vector<int>> F) {
	n = N;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i][j] = F[i][j];
			if (A[i][j] == 1) ls.pb(Mp(i, j));
		}
	}
	
	if (len(ls) == 0) return (n * n);
	else if (len(ls) == 1) {
		int i = ls.back().F, j = ls.back().S;
		return (n * n) - (min(i + 1, n - i) * min(j + 1, n - j));
	}
	
	return check();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 1 ms 2652 KB ok
8 Correct 13 ms 5276 KB ok
9 Correct 197 ms 47404 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Incorrect 0 ms 348 KB wrong
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -