Submission #1238155

#TimeUsernameProblemLanguageResultExecution timeMemory
1238155matsakyannnSoccer Stadium (IOI23_soccer)C++20
Compilation error
0 ms0 KiB
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
const int inf = 1e9;

int biggest_stadium(int N, vector <vector <int>> F){
    bool okay = 1;
    for(int i = 0; i < N; i++){
        int st = -1;
        for(int j = 0; j < N; j++){
            if(!F[i][j]){
                st = j; break;
            }
        }
        if(st == -1) continue;
        bool tree_on_road = 0;
        for(int j = st; j < N; j++){
            if(F[i][j]){
                tree_on_road = 1;
                continue;
            }
            if(tree_on_road) okay = 0;
        }
    }
    for(int j = 0; j < N; j++){
        int st = -1;
        for(int i = 0; i < N; i++){
            if(!F[i][j]){
                st = i;
                break;
            }
        }
        if(st == -1) continue;
        bool tree_on_road = 0;
        for(int i = st; i < N; i++){
            if(F[i][j]){
                tree_on_road = 1;
                continue;
            }
            if(tree_on_road) okay = 0;
        }
    }

    if(okay){
        int count = 0;
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                count += F[i][j];
            }
        }

        int vis_count = 0;
        for(int i = 0; i < N; i++){
            bool flag = 0;
            for(int j = 0; j < N; j++){
                if(!F[i][j]){
                    flag = 1;
                    bool visited[2005][2005] = {0};
                    queue <PII> q;
                    q.push({i, j});
                    while(!q.empty()){
                        int x = q.front().first, y = q.front().second;
                        //dbg(MP(x, y));
                        q.pop();
                        if(visited[x][y]) continue;
                        vis_count++;
                        visited[x][y] = 1;
                        for(int t = 0; t < 4; t++){
                            int nx = x + dx[t], ny = y + dy[t];
                            if(nx < 0 || ny < 0 || nx >= N || ny >= N) continue;
                            if(F[nx][ny]) continue;
                            q.push({nx, ny});
                        }
                    }
                    break;
                }
            }
            if(flag) break;
        }
        if(vis_count == N * N - count) return N * N - count;
    }
    return inf;
}

Compilation message (stderr)

soccer.cpp:5:36: error: 'vector' was not declared in this scope
    5 | int biggest_stadium(int N, vector <vector <int>> F){
      |                                    ^~~~~~
soccer.cpp:5:36: error: 'vector' was not declared in this scope
soccer.cpp:5:36: error: 'vector' was not declared in this scope
soccer.cpp:5:36: error: 'vector' was not declared in this scope
soccer.cpp:5:28: error: 'vector' has not been declared
    5 | int biggest_stadium(int N, vector <vector <int>> F){
      |                            ^~~~~~
soccer.cpp:5:35: error: expected ',' or '...' before '<' token
    5 | int biggest_stadium(int N, vector <vector <int>> F){
      |                                   ^
soccer.cpp: In function 'int biggest_stadium(int, int)':
soccer.cpp:10:17: error: 'F' was not declared in this scope
   10 |             if(!F[i][j]){
      |                 ^
soccer.cpp:17:16: error: 'F' was not declared in this scope
   17 |             if(F[i][j]){
      |                ^
soccer.cpp:27:17: error: 'F' was not declared in this scope
   27 |             if(!F[i][j]){
      |                 ^
soccer.cpp:35:16: error: 'F' was not declared in this scope
   35 |             if(F[i][j]){
      |                ^
soccer.cpp:47:26: error: 'F' was not declared in this scope
   47 |                 count += F[i][j];
      |                          ^
soccer.cpp:55:21: error: 'F' was not declared in this scope
   55 |                 if(!F[i][j]){
      |                     ^
soccer.cpp:58:28: error: 'PII' was not declared in this scope
   58 |                     queue <PII> q;
      |                            ^~~
soccer.cpp:58:21: error: 'queue' was not declared in this scope
   58 |                     queue <PII> q;
      |                     ^~~~~
soccer.cpp:58:33: error: 'q' was not declared in this scope
   58 |                     queue <PII> q;
      |                                 ^
soccer.cpp:64:39: error: 'y' was not declared in this scope
   64 |                         if(visited[x][y]) continue;
      |                                       ^
soccer.cpp:66:36: error: 'y' was not declared in this scope
   66 |                         visited[x][y] = 1;
      |                                    ^