# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
841364 | hcng | Soccer Stadium (IOI23_soccer) | C++17 | 232 ms | 31764 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 <bits/stdc++.h>
#include "soccer.h"
using namespace std;
int biggest_stadium(int n, vector<vector<int>> f) {
int cnt = 0;
vector<pair<int, int>> v;
bool flag = false;
for (int i = 0; i < n; i++) {
int l = -1, r = -1;
for (int j = 0; j < n; j++) {
if (f[i][j] == 0) cnt++;
if (f[i][j] == 0 && l == -1) {
l = j;
}
if (f[i][j] == 0 && r != -1) {
return -1;
}
if (f[i][j] == 1 && l != -1) {
r = j - 1;
}
}
if (l != -1 && r == -1) r = n - 1;
if (!v.empty() && l == -1) {
flag = true;
}
if (flag && l != -1) {
return -1;
}
if (l != -1) v.emplace_back(l, r);
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
if ((v[i].first > v[j].first && v[i].second > v[j].second) || (v[i].first < v[j].first && v[i].second < v[j].second)) {
return -1;
}
}
}
flag = false;
for (int i = 1; i < v.size(); i++) {
if (!flag) {
if (!(v[i].first <= v[i - 1].first && v[i].second >= v[i - 1].first)) {
flag = true;
}
} else {
if (!(v[i].first >= v[i - 1].first && v[i].second <= v[i - 1].first)) {
return -1;
}
}
}
return cnt;
}
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... |