| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 959530 | nguyentunglam | Soccer Stadium (IOI23_soccer) | C++17 | 294 ms | 71364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 2010;
int n;
int a[N][N];
vector<int> arr[N];
int check_valid() {
for(int col = 0; col < n; col++) {
for(int row = 0; row < n; row++) if (a[row][col] == 0) arr[col].push_back(row);
}
int st = 0;
while (st < n && arr[st].empty()) st++;
if (st == n) return 0;
bool tie = 0;
int prel = 0, prer = 0, cnt = 0, _cnt = 0;
for(int i = st; i < n; i++) {
if (arr[i].empty()) break;
int l = arr[i][0], r = arr[i].back();
cnt += arr[i].size();
if (r - l + 1 != arr[i].size()) return 0;
if (i == st) {
prel = l;
prer = r;
continue;
}
if (l < prel && r < prer) return 0;
if (l > prel && r > prer) return 0;
if (l + r == prel + prer) continue;
if (l > prel || r < prer) {
if (tie == 0) tie = 1;
else return 0;
}
// cout << l << " " << r << endl;
}
// cout << cnt <<
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) _cnt += a[i][j] ^ 1;
if (cnt != _cnt) return 0;
return cnt;
}
int biggest_stadium(int N, std::vector<std::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];
// return 0;
return check_valid();
}
#ifdef ngu
int main()
{
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
int N;
assert(1 == scanf("%d", &N));
std::vector<std::vector<int>> F(N, std::vector<int>(N));
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
assert(1 == scanf("%d", &F[i][j]));
}
}
fclose(stdin);
int res = biggest_stadium(N, F);
printf("%d\n", res);
fclose(stdout);
return 0;
}
#endif // ngu
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
