Submission #839973

# Submission time Handle Problem Language Result Execution time Memory
839973 2023-08-30T23:20:58 Z grossly_overconfident Soccer Stadium (IOI23_soccer) C++17
1.5 / 100
543 ms 422832 KB
#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;

bool checkcell(int i, int j, int n, vector<vector<int>>& f){
    if (i < 0 || i >= n || j < 0 || j >= n || f[i][j] == 1){
        return false;
    }
    return true;
}

int dfs(int i, int j, int n, vector<vector<int>>& f){
    int t = 1;
    f[i][j] = 1;
    if (checkcell(i + 1, j, n, f)){
        t += dfs(i + 1, j, n, f);
    }
    if (checkcell(i - 1, j, n, f)){
        t += dfs(i - 1, j, n, f);
    }
    if (checkcell(i, j + 1, n, f)){
        t += dfs(i, j + 1, n, f);
    }
    if (checkcell(i, j - 1, n, f)){
        t += dfs(i, j - 1, n, f);
    }
    return t;
}

int biggest_stadium(int n, vector<vector<int>> f)
{
    int t = 0;
    int si, sj;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j){
            t += 1 - f[i][j];
            if (f[i][j] == 0){
                si = i;
                sj = j;
            }
        }
    }
    vector<vector<int>> f2 = f;
    if (dfs(si, sj, n, f2) != t){
        return 1;
    }
    for (int i = 0; i < n; ++i){
        bool opened = false, closed = false;
        for (int j = 0; j < n; ++j){
            if (f[i][j] == 0){
                if (closed){
                    return 1;
                }
                opened = true;
            }
            if (f[i][j] == 1){
                if (opened){
                    closed = true;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i){
        bool opened = false, closed = false;
        for (int j = 0; j < n; ++j){
            if (f[j][i] == 0){
                if (closed){
                    return 1;
                }
                opened = true;
            }
            if (f[j][i] == 1){
                if (opened){
                    closed = true;
                }
            }
        }
    }



    return t;
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:44:12: warning: 'si' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     if (dfs(si, sj, n, f2) != t){
      |         ~~~^~~~~~~~~~~~~~~
soccer.cpp:44:12: warning: 'sj' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 1 ms 212 KB ok
6 Partially correct 1 ms 212 KB partial
7 Partially correct 2 ms 1236 KB partial
8 Partially correct 32 ms 26540 KB partial
9 Partially correct 543 ms 422832 KB partial
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Partially correct 1 ms 212 KB partial
4 Partially correct 0 ms 212 KB partial
5 Incorrect 1 ms 212 KB wrong
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Partially correct 1 ms 212 KB partial
5 Partially correct 0 ms 212 KB partial
6 Incorrect 1 ms 212 KB wrong
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Partially correct 1 ms 212 KB partial
7 Partially correct 0 ms 212 KB partial
8 Incorrect 1 ms 212 KB wrong
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Partially correct 1 ms 212 KB partial
7 Partially correct 0 ms 212 KB partial
8 Incorrect 1 ms 212 KB wrong
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Correct 1 ms 212 KB ok
7 Partially correct 1 ms 212 KB partial
8 Partially correct 2 ms 1236 KB partial
9 Partially correct 32 ms 26540 KB partial
10 Partially correct 543 ms 422832 KB partial
11 Partially correct 1 ms 212 KB partial
12 Partially correct 0 ms 212 KB partial
13 Incorrect 1 ms 212 KB wrong
14 Halted 0 ms 0 KB -