답안 #1077317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077317 2024-08-27T05:13:22 Z emptypringlescan 축구 경기장 (IOI23_soccer) C++17
6 / 100
471 ms 149596 KB
#include <bits/stdc++.h>
using namespace std;
int biggest_stadium(int n,vector<vector<int> > arr){
	int close[2][n][n];
	for(int j=0; j<n; j++){
		int prv=-1;
		for(int i=0; i<n; i++){
			if(arr[i][j]) prv=i;
			close[0][i][j]=prv;
		}
		prv=n;
		for(int i=n-1; i>=0; i--){
			if(arr[i][j]) prv=i;
			close[1][i][j]=prv;
		}
	}
	int yay[4][n+5][n+5];
	memset(yay,0,sizeof(yay));
	for(int i=0; i<n; i++){
		vector<pair<int,pair<int,int> > > mono;
		//area 0
		mono.push_back({n+5,{-1,0}});
		int val=0;
		for(int j=0; j<n; j++){
			while(!mono.empty()&&mono.back().first<close[0][i][j]){
				val-=mono.back().second.second;
				mono.pop_back();
			}
			int more=(close[0][i][j]+1)*(j-mono.back().second.first);
			val+=more;
			mono.push_back({close[0][i][j],{j,more}});
			yay[0][i+1][j+1]=val;
		}
		//area 1
		mono.clear();
		mono.push_back({n+5,{n,0}});
		val=0;
		for(int j=n-1; j>=0; j--){
			while(!mono.empty()&&mono.back().first<close[0][i][j]){
				val-=mono.back().second.second;
				mono.pop_back();
			}
			int more=(close[0][i][j]+1)*(mono.back().second.first-j);
			val+=more;
			mono.push_back({close[0][i][j],{j,more}});
			yay[1][i+1][j+1]=val;
		}
		//area 2
		mono.clear();
		mono.push_back({-1,{-1,0}});
		val=0;
		for(int j=0; j<n; j++){
			while(!mono.empty()&&mono.back().first>close[1][i][j]){
				val-=mono.back().second.second;
				mono.pop_back();
			}
			int more=(n-close[1][i][j])*(j-mono.back().second.first);
			val+=more;
			mono.push_back({close[1][i][j],{j,more}});
			yay[2][i+1][j+1]=val;
		}
		//area 3
		mono.clear();
		mono.push_back({-1,{n,0}});
		val=0;
		for(int j=n-1; j>=0; j--){
			while(!mono.empty()&&mono.back().first>close[1][i][j]){
				val-=mono.back().second.second;
				mono.pop_back();
			}
			int more=(n-close[1][i][j])*(mono.back().second.first-j);
			val+=more;
			mono.push_back({close[1][i][j],{j,more}});
			yay[3][i+1][j+1]=val;
		}
	}
	int pref[n+1][n+1];
	memset(pref,0,sizeof(pref));
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			pref[i+1][j+1]=pref[i+1][j]+pref[i][j+1]-pref[i][j]+arr[i][j];
		}
	}
	int ans=0;
	for(int a=0; a<n; a++){
		for(int b=0; b<n; b++){
			ans=max(ans,n*n-yay[0][a][b+1]-yay[1][a][b+2]-yay[2][a+1][b+1]-yay[3][a+1][b+2]);
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 1 ms 440 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 1 ms 604 KB ok
8 Correct 28 ms 9808 KB ok
9 Correct 471 ms 149596 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Incorrect 0 ms 348 KB wrong
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB ok
2 Correct 1 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Incorrect 0 ms 348 KB wrong
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB ok
2 Correct 1 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 1 ms 440 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Incorrect 0 ms 348 KB wrong
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB ok
2 Correct 1 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 1 ms 440 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Incorrect 0 ms 348 KB wrong
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB ok
2 Correct 1 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 1 ms 440 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 1 ms 348 KB ok
8 Correct 1 ms 604 KB ok
9 Correct 28 ms 9808 KB ok
10 Correct 471 ms 149596 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Incorrect 0 ms 348 KB wrong
14 Halted 0 ms 0 KB -