이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
int n, e;
vector<vector<int>> f;
int biggest_stadium(int N, vector<vector<int>> F) {
n = N;
f = F;
// se pueden coger todas las empty cells?
bool ok = 1;
e = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
e += !f[i][j];
}
}
vector<pair<int, int>> s[2];
s[0].resize(n);
s[1].resize(n);
for (int i = 0; i < n; i++) {
int l = inf;
int r = -inf;
for (int j = 0; j < n; j++) {
if (f[i][j] == 1) continue;
l = min(l, j);
r = max(r, j);
}
s[0][i] = make_pair(l, r);
for (int j = l; j <= r; j++) {
if (f[i][j] == 1) ok = 0;
}
l = inf;
r = -inf;
for (int j = 0; j < n; j++) {
if (f[j][i] == 1) continue;
l = min(l, j);
r = max(r, j);
}
s[1][i] = make_pair(l, r);
for (int j = l; j <= r; j++) {
if (f[j][i] == 1) ok = 0;
}
}
for (int x = 0; x < n; x++) {
for (int y = x+1; y < n; y++) {
pair<int, int> a = s[0][x];
pair<int, int> b = s[0][y];
if (!(a.first <= b.first && b.second <= a.second) && !(b.first <= a.first && a.second <= b.second)) {
ok = 0;
}
a = s[1][x];
b = s[1][y];
if (!(a.first <= b.first && b.second <= a.second) && !(b.first <= a.first && a.second <= b.second)) {
ok = 0;
}
}
}
if (ok) return e;
// hay solo un tree?
if (e == n*n-1) {
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (f[i][j] == 1) {
ans = max(ans, n*n - (i+1)*(j-1) + 1);
ans = max(ans, n*n - (n-i)*(j+1) + 1);
ans = max(ans, n*n - (i+1)*(n-j) + 1);
ans = max(ans, n*n - (n-i)*(n-j) + 1);
break;
}
}
}
return ans;
}
// else
return 1e9;
}
# | 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... |