답안 #1067696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067696 2024-08-21T01:08:01 Z aaaaaarroz 축구 경기장 (IOI23_soccer) C++17
0 / 100
0 ms 348 KB
    #include <bits/stdc++.h>
    using namespace std;
    bool limites(int N, int i, int j){
    	return i>=0&&i<N&&j>=0&&j<N;
    }
    bool comprobar(int N, vector<vector<int>> F){
    	for(int i=0;i<N;i++){
    		for(int j=0;j<N;j++){
    			if(F[i][j]==1||F[i][j]==0){
    				continue;
    			}
    			priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>>cola;
    			int dx[]={1,0,-1,0};
    			int dy[]={0,1,0,-1};
    			vector<vector<int>>dist(N,vector<int>(N,INT_MAX));
    			dist[i][j]=0;
    			cola.push({0,i,j});
    			while(!cola.empty()){
    				auto[d,x,y]=cola.top();
    				cola.pop();
    				for(int dir=0;dir<4;dir++){
    					int posi=x+dx[dir];
    					int posj=y+dy[dir];
    					while(true){
    						if(!limites(N,posi,posj)||F[posi][posj]==1||F[posi][posj]==0)break;
    						if((d+1)<dist[posi][posj]){
    							dist[posi][posj]=d+1;
    							cola.push({dist[posi][posj],posi,posj});
    						}
    						posi+=dx[dir];
    						posj+=dy[dir];
    					}
    				}
    			}
    			for(int x=0;x<N;x++){
    				for(int y=0;y<N;y++){
    					if(F[x][y]==2&&(dist[x][y]>=3||dist[x][y]==-1)){
    						return false;
    					}
    				}
    			}
    		}
    	}
    	return true;
    }
    int biggest_stadium(int N, vector<vector<int>> F) {
        int best = 0;
        for (int fila = 0; fila < N; fila++) {
            vector<pair<int, int>> almacen; // Almacena los rangos de columnas válidas
            for (int columna = 0; columna < N; columna++) {
                if (F[fila][columna] == 0) {
                    int ini = columna;
                    while (columna < N && F[fila][columna] == 0) columna++;
                    almacen.push_back({ini, columna - 1});
                }
            }
     
            for (int columna = 0; columna < almacen.size(); columna++) {
                int suma = almacen[columna].second - almacen[columna].first + 1;
                vector<vector<int>> grid(N, vector<int>(N, 0));
     
                int cnt = 0;
                int fil = fila;
                while (fil >= 0 && F[fil][almacen[columna].first] == 0 && F[fil][almacen[columna].second] == 0) {
                    for (int y = almacen[cnt].first; y <= almacen[cnt].second; y++) {
                        grid[fil][y] = 2;
                    }
                    fil--;
                    cnt++;
                }
     
                cnt = 0;
                fil = fila;
                while (fil < N && F[fil][almacen[columna].first] == 0 && F[fil][almacen[columna].second] == 0) {
                    for (int y = almacen[cnt].first; y <= almacen[cnt].second; y++) {
                        grid[fil][y] = 2;
                    }
                    fil++;
                    cnt++;
                }
     
                if (comprobar(N, grid)) {
                    best = max(suma, best);
                }
            }
        }
        return best;
    }

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:58:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for (int columna = 0; columna < almacen.size(); columna++) {
      |                                   ~~~~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -