Submission #996941

#TimeUsernameProblemLanguageResultExecution timeMemory
996941MilosMilutinovicSoccer Stadium (IOI23_soccer)C++17
30 / 100
4596 ms11664 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; const int MAX = 2005; int n, a[MAX][MAX]; int L[MAX][MAX]; int R[MAX][MAX]; int go[MAX][MAX]; int res; map<array<int, 5>, bool> was; void rec(int xl, int xr, int yl, int yr, int cur) { if (was[{xl, xr, yl, yr, cur}]) { return; } res = max(res, cur); was[{xl, xr, yl, yr}] = true; if (xl > 0) { // up int ptr = yl; while (ptr <= yr) { if (a[xl - 1][ptr] == 1) { ptr = go[xl - 1][ptr]; continue; } int t = min(yr, R[xl - 1][ptr]); rec(xl - 1, xr, ptr, t, cur + t - ptr + 1); ptr = R[xl - 1][ptr] + 1; } } if (xr + 1 < n) { // down int ptr = yl; while (ptr <= yr) { if (a[xr + 1][ptr] == 1) { ptr = go[xr + 1][ptr]; continue; } int t = min(yr, R[xr + 1][ptr]); rec(xl, xr + 1, ptr, t, cur + t - ptr + 1); ptr = R[xr + 1][ptr] + 1; } } } int biggest_stadium(int N, vector<vector<int>> F) { n = N; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = F[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 1) { continue; } int p = j; while (p + 1 < n && a[i][p + 1] == 0) { p += 1; } for (int k = j; k <= p; k++) { L[i][k] = j; R[i][k] = p; } j = p; } } for (int i = 0; i < n; i++) { for (int j = n - 1; j >= 0; j--) { if (a[i][j] == 1) { go[i][j] = (j == n - 1 ? n : go[i][j + 1]); } else { go[i][j] = j; } } } res = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] == 1) { continue; } if (j == 0 || a[i][j - 1] == 1) { rec(i, i, j, R[i][j], R[i][j] - j + 1); } } } return res; }
#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...