# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1000747 | kunzaZa183 | Soccer Stadium (IOI23_soccer) | C++17 | 208 ms | 39044 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;
int biggest_stadium(int N, vector<vector<int>> F) {
vector<pair<int, int>> vpii;
int cur;
for (int i = 0; i < N; i++) {
pair<int, int> pii = {-1, -1};
cur = 0;
for (int j = 0; j < N; j++)
if (cur == 0) {
if (F[i][j] == 0) {
cur++;
pii.first = j;
}
} else if (cur == 1) {
if (F[i][j] == 1) {
cur++;
pii.second = j - 1;
}
} else if (cur == 2)
if (F[i][j] == 0) return INT_MAX;
if (cur == 1) pii.second = N - 1;
vpii.push_back(pii);
}
// for (auto a : vpii) cout << a.first << " " << a.second << "\n";
cur = 0;
for (auto a : vpii)
if (cur == 0) {
if (a.first != -1) cur++;
} else if (cur == 1) {
if (a.first == -1) cur++;
} else if (cur == 2) {
if (a.first != -1) return INT_MAX;
}
while (!vpii.empty())
if (vpii.back().first == -1)
vpii.pop_back();
else
break;
while (!vpii.empty())
if (vpii.front().first == -1)
vpii.erase(vpii.begin());
else
break;
for (int i = 0; i < vpii.size(); i++) {
bool fails = 0;
for (int j = i - 1; j >= 0; j--)
if (vpii[j].first < vpii[j + 1].first ||
vpii[j].second > vpii[j + 1].second)
fails = 1;
for (int j = i + 1; j < vpii.size(); j++)
if (vpii[j].first < vpii[j - 1].first ||
vpii[j].second > vpii[j - 1].second)
fails = 1;
if (!fails) goto A;
}
return INT_MAX;
A:;
vpii.clear();
for (int j = 0; j < N; j++) {
pair<int, int> pii = {-1, -1};
cur = 0;
for (int i = 0; i < N; i++)
if (cur == 0) {
if (F[i][j] == 0) {
cur++;
pii.first = i;
}
} else if (cur == 1) {
if (F[i][j] == 1) {
cur++;
pii.second = i - 1;
}
} else if (cur == 2)
if (F[i][j] == 0) return INT_MAX;
if (cur == 1) pii.second = N - 1;
vpii.push_back(pii);
}
// for (auto a : vpii) cout << a.first << " " << a.second << '\n';
cur = 0;
for (auto a : vpii)
if (cur == 0) {
if (a.first != -1) cur++;
} else if (cur == 1) {
if (a.first == -1) cur++;
} else if (cur == 2) {
if (a.first != -1) return INT_MAX;
}
while (!vpii.empty())
if (vpii.back().first == -1)
vpii.pop_back();
else
break;
while (!vpii.empty())
if (vpii.front().first == -1)
vpii.erase(vpii.begin());
else
break;
for (int i = 0; i < vpii.size(); i++) {
bool fails = 0;
for (int j = i - 1; j >= 0; j--)
if (vpii[j].first < vpii[j + 1].first ||
vpii[j].second > vpii[j + 1].second)
fails = 1;
for (int j = i + 1; j < vpii.size(); j++)
if (vpii[j].first < vpii[j - 1].first ||
vpii[j].second > vpii[j - 1].second)
fails = 1;
if (!fails) {
int ct = 0;
for (auto a : F)
for (auto b : a) ct += 1 - b;
return ct;
}
}
return INT_MAX;
}
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... |