Submission #1070570

#TimeUsernameProblemLanguageResultExecution timeMemory
1070570becaidoSoccer Stadium (IOI23_soccer)C++17
100 / 100
536 ms147648 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifndef WAIMAI #include "soccer.h" #else #include "grader.cpp" #endif #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second const int SIZE = 2005; int n, ans; bool a[SIZE][SIZE]; vector<pair<int, int>> p[SIZE]; int U[SIZE][SIZE], L[SIZE][SIZE], R[SIZE][SIZE], dp[SIZE][SIZE]; int biggest_stadium(int N, vector<vector<int>> F) { n = N, ans = 0; FOR (i, 1, n) p[i].clear(); FOR (i, 1, n) FOR (j, 1, n) a[i][j] = F[i - 1][j - 1], dp[i][j] = 0; FOR (i, 1, n) { FOR (j, 1, n) { U[i][j] = (a[i][j] ? i : U[i - 1][j]); L[i][j] = (a[i][j] ? j : L[i][j - 1]); if (U[i][j] < i) p[i - U[i][j]].pb(i, j); } R[i][n + 1] = n + 1; for (int j = n; j >= 1; j--) R[i][j] = (a[i][j] ? j : R[i][j + 1]); } FOR (ulen, 1, n) for (auto [x, y] : p[ulen]) { if (ulen > 1) { L[x][y] = max(L[x][y], L[x - 1][y]); R[x][y] = min(R[x][y], R[x - 1][y]); } dp[x][y] = dp[x- 1][y] + (R[x][y] - L[x][y] - 1); if (L[x][y] >= 1) dp[x][y] = max(dp[x][y], dp[x][L[x][y]] + (U[x][L[x][y]] - U[x][y]) * (R[x][y] - L[x][y] - 1)); if (R[x][y] <= n) dp[x][y] = max(dp[x][y], dp[x][R[x][y]] + (U[x][R[x][y]] - U[x][y]) * (R[x][y] - L[x][y] - 1)); ans = max(ans, dp[x][y]); } return ans; } /* in1 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 out1 20 */
#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...