Submission #1070244

# Submission time Handle Problem Language Result Execution time Memory
1070244 2024-08-22T12:24:44 Z MohamedFaresNebili Soccer Stadium (IOI23_soccer) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#include "soccer.h"

        using namespace std;

        int solveA(int r, int i, int j, int N, vector<vector<int>> F) {
            if(r == N) return 0;
            int best = 0;
            for(int l = i; l <= j; l++) {
                int k = l;
                if(F[r][l] == 1) continue;
                while(k <= j && F[r][k] == 0) k++;
                best = max(best, k - l + solveA(r + 1, l, k - 1, N, F));
                l = k - 1;
            }
            return best;
        }
        int solveB(int r, int i, int j, int N, vector<vector<int>> F) {
            if(r == -1) return 0;
            int best = 0;
            for(int l = i; l <= j; l++) {
                int k = l;
                if(F[r][l] == 1) continue;
                while(k <= j && F[r][k] == 0) k++;
                best = max(best, k - l + solveB(r - 1, l, k - 1, N, F));
                l = k - 1;
            }
            return best;
        }

        int solveC(int r, int i, int j, int N, vector<vector<int>> F) {
            if(r == N) return 0;
            int best = 0;
            for(int l = i; l <= j; l++) {
                int k = l;
                if(F[l][r] == 1) continue;
                while(k <= j && F[k][r] == 0) k++;
                best = max(best, k - l + solveC(r + 1, l, k - 1, N, F));
                l = k - 1;
            }
            return best;
        }
        int solveD(int r, int i, int j, int N, vector<vector<int>> F) {
            if(r == -1) return 0;
            int best = 0;
            for(int l = i; l <= j; l++) {
                int k = l;
                if(F[l][r] == 1) continue;
                while(k <= j && F[k][r] == 0) k++;
                best = max(best, k - l + solveD(r - 1, l, k - 1, N, F));
                l = k - 1;
            }
            return best;
        }

        int biggest_stadium(int N, vector<vector<int>> F) {
            int res = 0;
                    for(int r = 0; r < N; r++) {
                        int A = solveA(r, 0, N - 1, N, F);
                        int B = solveB(r, 0, N - 1, N, F);
                        int C = solveC(r, 0, N - 1, N, F);
                        int D = solveD(r, 0, N - 1, N, F);
                        res = max({A, B, C, D});
                    }

            return res;
        }
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -