Submission #1041953

#TimeUsernameProblemLanguageResultExecution timeMemory
1041953ZanPSoccer Stadium (IOI23_soccer)C++17
0 / 100
4552 ms70920 KiB
#include "soccer.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; int biggest_stadium(int n, vector<vector<int>> grid) { vector<vector<int>> dist_up(n, vector<int>(n, 0)), dist_down(n, vector<int>(n, 0)); for (int i = 0; i < n; i++) { dist_up[0][i] = 1 - grid[0][i]; dist_down[n - 1][i] = 1 - grid[n - 1][i]; } for (int i = 1; i < n; i++) { for (int j = 0; j < n; j++) { dist_up[i][j] = grid[i][j] ? 0 : 1 + dist_up[i - 1][j]; dist_down[n - i - 1][j] = grid[n - i - 1][j] ? 0 : 1 + dist_down[n - i][j]; } } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (grid[i][j]) { continue; } int dist = dist_up[i][j]; int sub_ans = dist; for (int x = j - 1; dist && x >= 0; x--) { dist = min(dist_up[i][x], dist); sub_ans += dist; } for (int x = j + 1; dist && x < n; x++) { dist = min(dist_up[i][x], dist); sub_ans += dist; } dist = dist_down[i][j] - 1; sub_ans += dist; for (int x = j - 1; dist && x >= 0; x--) { dist = min(dist_down[i][x] - 1, dist); if (dist < 0) { break; } sub_ans += dist; } for (int x = j + 1; dist && x < n; x++) { dist = min(dist_down[i][x] - 1, dist); if (dist < 0) { break; } sub_ans += dist; } ans = max(ans, sub_ans); } } return ans; } // int main() { // cout << biggest_stadium(5, { {0, 0, 0, 0, 0}, // {1, 0, 0, 0, 0}, // {0, 0, 0, 0, 0}, // {0, 0, 0, 0, 0}, // {0, 0, 1, 0, 0} }) << '\n'; // }
#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...