이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int ASC = 0;
const int DESC = 1;
void minSelf(int &x, int y) {
	if(y < x) {
		x = y;
	}
}
void maxSelf(int &x, int y) {
	if(y > x) {
		x = y;
	}
}
// a before b
int trend(const pii &a, const pii &b) {
	if(a.first >= b.first && a.second <= b.second) {
		return ASC;
	}
	if(a.first <= b.first && a.second >= b.second) {
		return DESC;
	}
	return -1;
}
int biggest_stadium(int n, std::vector<std::vector<int>> v)
{
	int x = -1, y = -1, cnt = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(v[i][j] == 1) {
				cnt++;
				x = i;
				y = j;
			}
		}
	}
	if(cnt == 1) {
		return n * n - min({(x + 1) * (y + 1), (x + 1) * (n - y + 1), (n - x + 1) * (y + 1), (n - x + 1) * (n - y + 1)});
	} else if(cnt == 0) {
		return n * n;
	}
	vector<vector<pii>> intervals;
	for(int i = 0; i < n; i++) {
		intervals.emplace_back(vector<pii>(0));
		int lst = -1;
		for(int j = 0; j < n; j++) {
			if(v[i][j] == 0 && lst == -1) {
				lst = j;
			} else if(v[i][j] == 1 && lst != -1) {
				intervals.back().emplace_back(lst, j - 1);
				lst = -1;
			}
		}
		if(lst != -1) {
			intervals.back().emplace_back(lst, n - 1);
		}
		if(intervals.back().size() == 0) {
			intervals.pop_back();
		}
	}
	if(false) {
		return 0;
	} else {
		if(!intervals.empty()) {
			for(const auto &row: intervals) {
				if(row.size() > 1) {
					return 0;
				}
			}
			int lst = ASC;
			pair<int, int> in = intervals[0][0];
			for(int i = 1; i < (int) intervals.size(); i++) {
				maxSelf(in.first, intervals[i][0].first);
				minSelf(in.second, intervals[i][0].second);
				if(in.first > in.second) {
					return 0;
				}
				int crt = trend(intervals[i - 1][0], intervals[i][0]);
				if(crt == -1) {
					return 0;
				}
				if(lst == ASC && crt == DESC) {
					lst = DESC;
				} else if(lst == DESC && crt == ASC) {
					return 0;
				}
			}
		}
		return n * n - cnt;
	}
	return 0;
}
/*
5
1 1 0 1 1
1 0 0 0 1
1 0 0 1 1
1 0 1 1 1
1 1 1 1 1
------------
5
1 1 0 1 1
1 0 0 0 1
1 0 0 1 1
1 1 0 1 1
1 1 1 1 1
*/
/*
    [-----]
   [--------]
  [-------------]
  	[---]
*/
| # | 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... |