Submission #1072322

#TimeUsernameProblemLanguageResultExecution timeMemory
1072322sammyuriSoccer Stadium (IOI23_soccer)C++17
48 / 100
709 ms12164 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 31; // dp[i][j][k][l] = biggest stadium that can fit in rows i..j, // columns k..l currently active int dp[MAXN][MAXN][MAXN][MAXN]; int biggest_stadium(int N, std::vector<std::vector<int>> F) { int n = N; for (int i = 0; i < n; i ++) for (int j = 0; j < n; j ++) for (int k = 0; k < n; k ++) for (int l = 0; l < n; l ++) dp[i][j][k][l] = -1e9; for (int i = 0; i < n; i ++) { for (int k = 0; k < n; k ++) { for (int l = k; l < n; l ++) { bool free = true; for (int ii = k; ii <= l; ii ++) if (F[i][ii]) free = false; if (!free) continue; dp[i][i][k][l] = l - k + 1; } } } for (int height = 2; height <= n; height ++) { for (int i = 0; i < n - height + 1; i ++) { int j = i + height - 1; // add on top for (int k = 0; k < n; k ++) { for (int l = k; l < n; l ++) { bool free = true; for (int ii = k; ii <= l; ii ++) if (F[i][ii]) free = false; if (!free) continue; int best = -1e9; for (int kk = k; kk >= 0; kk --) for (int ll = l; ll < n; ll ++) best = max(best, dp[i + 1][j][kk][ll]); // cout << i << " " << j << " " << k << " " << l << " " << best << " "; dp[i][j][k][l] = max(dp[i][j][k][l], best + l - k + 1); } } // add on bottom for (int k = 0; k < n; k ++) { for (int l = k; l < n; l ++) { bool free = true; for (int ii = k; ii <= l; ii ++) if (F[j][ii]) free = false; if (!free) continue; int best = -1e9; for (int kk = k; kk >= 0; kk --) for (int ll = l; ll < n; ll ++) best = max(best, dp[i][j - 1][kk][ll]); // cout << i << " " << j << " " << k << " " << l << " " << best << " "; dp[i][j][k][l] = max(dp[i][j][k][l], best + l - k + 1); } } } } int best = 0; for (int i = 0; i < n; i ++) for (int j = 0; j < n; j ++) for (int k = 0; k < n; k ++) for (int l = 0; l < n; l ++) best = max(best, dp[i][j][k][l]); return best; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...