Submission #937309

# Submission time Handle Problem Language Result Execution time Memory
937309 2024-03-03T19:44:21 Z Dan4Life Soccer Stadium (IOI23_soccer) C++17
0 / 100
4500 ms 348 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;

#define pf push_front
#define pb push_back
#define ll long long
#define vi vector<int>
#define sz(a) (int)a.size()
#define lb lower_bound
#define ub upper_bound
#define all(a) begin(a),end(a)

const int mxN = 2010;
int n;
vector<int> col[mxN];

int biggest_stadium(int N, vector<vi> a)
{
	n = N; int ans = 0;
	
	for(int i = 0; i < n; i++) 
		col[i].clear(), col[i].pb(-1);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			if(a[i][j]) col[j].pb(i);
	for(int i = 0; i < n; i++) col[i].pb(n);
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i][j]) continue;
			for(int k = i; k < n; k++){
				if(a[k][j]) break; 
				int mxJ = j;
				for (int l = j; l < n; l++){
					int pos = lb(all(col[l]),i)-begin(col[l]);
					if(col[l][pos]<=k) break; // if a[i][l]...a[k][l] contains forest
					mxJ = l;
				}
				
				for(int l = j; l <= mxJ; l++){
					int tot = 0;
					int pos = lb(all(col[l]),i)-begin(col[l]);
					if(col[l][pos]<=k) break; // if a[i][l]...a[k][l] contains forest
					
					int DOWN = i, UP = i;
					while(UP>0 and !a[UP-1][l]) UP--;   		// while we dont have forest, go up
					while(DOWN<n-1 and !a[DOWN+1][l]) DOWN++; 	//          " "               go down
					tot+=DOWN-UP+1;
					int up2 = UP, down2 = DOWN;
					
					for(int m = l-1; m >= j; m--){
						int pos = lb(all(col[m]),i)-begin(col[m]);
						int up = max(UP, col[m][pos-1]+1); 
						int down = min(DOWN, col[m][pos]-1);
						UP = up, DOWN = down; tot+=down-up+1;
					}
					UP = up2, DOWN = down2;
					for(int m = l+1; m <= mxJ; m++){
						int pos = lb(all(col[m]),i)-begin(col[m]);
						int up = max(UP, col[m][pos-1]+1); 
						int down = min(DOWN, col[m][pos]-1);
						UP = up, DOWN = down; tot+=down-up+1;
					}
					ans = max(ans, tot); 
					//cout << i << " " << j << " " << k << " " << l << " " << down2 << " " << up2 << " " << tot << "\n";
				}
			}
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Execution timed out 4582 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Incorrect 0 ms 348 KB wrong
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 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 0 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Incorrect 0 ms 348 KB wrong
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 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 0 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Incorrect 0 ms 348 KB wrong
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Execution timed out 4582 ms 348 KB Time limit exceeded
9 Halted 0 ms 0 KB -