Submission #1066442

# Submission time Handle Problem Language Result Execution time Memory
1066442 2024-08-19T21:47:48 Z aaaaaarroz Soccer Stadium (IOI23_soccer) C++17
0 / 100
4500 ms 1214288 KB
    #include <bits/stdc++.h>
    using namespace std;
    int biggest_stadium(int N, vector<vector<int>> F){
    	map<tuple<int,int,int>,bool>libre;
    	for(int fila=0;fila<N;fila++){
    		for(int i=0;i<N;i++){
    			for(int j=0;j<N;i++){
    				if(i==j){
    					libre[{fila,i,j}]=!F[fila][j];
    				}
    				else{
    					libre[{fila,i,j}]=(!F[fila][j])&&libre[{fila,i,j-1}];
    				}
    			}
    		}
    	}
    	int best=0;
    	for(int fila=0;fila<N;fila++){
    		for(int columna=0;columna<N;columna++){
    			for(int i=0;i<=columna;i++){
    				for(int j=columna;j<N;j++){
    					if(libre[{fila,i,j}]){
    						vector<pair<int,int>>almacen;
    						almacen.push_back({i,j});
    						int suma=0;
    						int fil=fila-1;
    						while(fil>=0&&F[fil][columna]==1){
    							int l=columna,r=columna;
    							while(l>almacen.back().first&&r<almacen.back().second){
    								if(libre[{fil,l-1,r}]){
    									l--;
    								}
    								else if(libre[{fil,l,r+1}]){
    									r++;
    								}
    								else{
    									break;
    								}
    							}
    							almacen.push_back({l,r});
    							fil--;
    						}
    						almacen.push_back({i,j});
    						fil=fila+1;
    						int fila_extra=1;
    						int alm_ant=almacen.size()-1;
    						while(fil<N&&F[fil][columna]==1){
    							int l1=columna,r1=columna;
    							if(fila_extra<alm_ant){
    								l1=almacen[alm_ant].first;
    								r1=almacen[alm_ant].second;
    								while(l1>almacen.back().first&&r1<almacen.back().second){
    									if(libre[{fil,l1-1,r1}]){
    										l1--;
    									}
    									else if(libre[{fil,l1,r1+1}]){
    										r1++;
    									}
    									else{
    										break;
    									}
    								}
    								int l=columna,r=columna;
    								while(l>almacen[fila_extra].first&&r<almacen[fila_extra].second){
    									if(libre[{fil,l-1,r}]){
    										l--;
    									}
    									else if(libre[{fil,l,r+1}]){
    										r++;
    									}
    									else{
    										break;
    									}
    								}
    								if(libre[{fil,l1,r1}]){
    									almacen.push_back({l1,r1});
    								}
    								else{
    									almacen.push_back({l,r});
    								}
    							}
								else{
									int l=columna,r=columna;
									while(l>almacen.back().first&&r<almacen.back().second){
										if(libre[{fil,l-1,r}]){
											l--;
										}
										else if(libre[{fil,l,r+1}]){
											r++;
										}
										else{
											break;
										}
									}
									almacen.push_back({l,r});
									fil++;
								}
    						}
    						for(auto[x,y]:almacen){
    							suma+=(y-x+1);
    						}
    						suma-=(j-i+1);
    						best=max(suma,best);
    						fila_extra++;
    					}
    					else{
    						continue;
    					}
    				}
    			}
    		}
    	}
    	return best;
    }
# Verdict Execution time Memory Grader output
1 Execution timed out 4548 ms 1134160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4579 ms 1214288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4579 ms 1214288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4548 ms 1134160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4548 ms 1134160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4548 ms 1134160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4548 ms 1134160 KB Time limit exceeded
2 Halted 0 ms 0 KB -