Submission #1070240

# Submission time Handle Problem Language Result Execution time Memory
1070240 2024-08-22T12:23:11 Z MohamedFaresNebili Soccer Stadium (IOI23_soccer) C++17
0 / 100
1 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 l = 0; l < N; l++) {
                for(int i = l; i < N; i++) {
                    for(int r = 0; r < N; r++) {
                        int A = solveA(r, l, i, N, F);
                        int B = solveB(r, l, i, N, F);
                        int C = solveC(r, l, i, N, F);
                        int D = solveD(r, l, i, N, F);
                        res = max({A, B, C, D});
                    }

                }
            }

            return res;
        }
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB partial
# 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 Partially correct 1 ms 344 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB partial
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -