Submission #846495

#TimeUsernameProblemLanguageResultExecution timeMemory
846495AndreySoccer Stadium (IOI23_soccer)C++17
0 / 100
1 ms4444 KiB
#include "soccer.h" #include<bits/stdc++.h> using namespace std; int haha[3001][3001]; int l[3001][3001]; int r[3001][3001]; int n; int calc(const vector<int>& haha) { int n = haha.size(); vector<int> bruh(n); vector<int> wow(n); stack<pair<int,int>> idk; for(int i = 0; i < n; i++) { int a = haha[i]; while(!idk.empty() && a <= idk.top().first) { idk.pop(); } if(idk.empty()) { bruh[i] = (i+1)*a; } else { bruh[i] = bruh[idk.top().second]+a*(i-idk.top().second); } idk.push({a,i}); } while(!idk.empty()) { idk.pop(); } for(int i = n-1; i >= 0; i--) { int a = haha[i]; while(!idk.empty() && a <= idk.top().first) { idk.pop(); } if(idk.empty()) { wow[i] = (n-i)*a; } else { wow[i] = wow[idk.top().second]+a*(idk.top().second-i)+a-idk.top().second; } idk.push({a,i}); } int ans = 0; for(int i = 0; i < n; i++) { ans = max(ans,bruh[i]+wow[i]-haha[i]); } return ans; } int biggest_stadium(int N, std::vector<std::vector<int>> f) { n = N; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { haha[i][j] = f[i][j]; } } for(int i = 0; i < n; i++) { if(haha[i][0]) { l[i][0] = -1; } else { l[i][0] = 0; } for(int j = 1; j < n; j++) { if(haha[i][j]) { l[i][j] = -1; } else { l[i][j] = l[i][j-1]+1; } } if(haha[i][n-1]) { r[i][n-1] = -1; } else { r[i][n-1] = 0; } for(int j = n-2; j >= 0; j--) { if(haha[i][j]) { r[i][j] = -1; } else { r[i][j] = r[i][j+1]+1; } } } int ans = 0; for(int i = 0; i < n; i++) { vector<int> yay(0); vector<int> wut(0); for(int j = 0; j < n; j++) { if(l[i][j] == -1) { if(yay.size() > 0) { ans = max(ans,calc(yay)+calc(wut)+(int)yay.size()); } yay.clear(); wut.clear(); } else { yay.push_back(l[j][i]); wut.push_back(r[j][i]); } } if(yay.size() > 0) { ans = max(ans,calc(yay)+calc(wut)+(int)yay.size()); } } return ans; }
#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...