Submission #1108889

#TimeUsernameProblemLanguageResultExecution timeMemory
1108889jerzykSoccer Stadium (IOI23_soccer)C++17
6 / 100
295 ms94772 KiB
#include <bits/stdc++.h> #include "soccer.h" using namespace std; #define pb push_back #define st first #define nd second typedef long long ll; typedef long double ld; const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL; const int II = 2 * 1000 * 1000 * 1000; const ll M = 1000LL * 1000LL * 1000LL + 7LL; const int N = 2'007; int tab[N][N]; int nxt[N][N][2]; int dod[N][N]; void Cnt(int n) { for(int i = 1; i <= n; ++i) { for(int r = 0; r < 2; ++r) {nxt[i][0][r] = -1; nxt[i][n + 1][r] = -1;} for(int r = 0; r < 2; ++r) { vector<int> cur; int s = 0; cur.pb(0); for(int j = 1; j <= n; ++j) { while(nxt[i][cur.back()][r] >= nxt[i][j][r]) { int xd = cur.back(); cur.pop_back(); s -= (xd - cur.back()) * nxt[i][xd][r]; } s += (j - cur.back()) * nxt[i][j][r]; //if(r == 1) //cout << i << " " << j << " " << nxt[i][j][r] << " " << cur.back() << " " << s << "\n"; cur.pb(j); dod[i][j] += s; } cur.clear(); s = 0; cur.pb(n + 1); for(int j = n; j >= 1; --j) { while(nxt[i][cur.back()][r] >= nxt[i][j][r]) { int xd = cur.back(); cur.pop_back(); s -= (cur.back() - xd) * nxt[i][xd][r]; } s += (cur.back() - j) * nxt[i][j][r]; //if(r == 0) //cout << i << " " << j << " " << nxt[i][j][r] << " " << cur.back() << " " << s << "\n"; cur.pb(j); dod[i][j] += s - nxt[i][j][r]; } //cout << "\n"; } int cnt = 0; for(int j = 1; j <= n; ++j) { ++cnt; if(tab[i][j] == 1) cnt = 0; //cout << dod[i][j] << " "; dod[i][j] -= cnt; } //cout << "\n"; cnt = 0; for(int j = n; j >= 1; --j) { ++cnt; if(tab[i][j] == 1) cnt = 0; dod[i][j] -= (cnt - 1); } } } int biggest_stadium(int _N, vector<vector<int>> _F) { int n = _N; for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) { tab[i][j] = _F[i - 1][j - 1]; nxt[i][j][0] = nxt[i - 1][j][0] + 1; if(tab[i][j] == 1) nxt[i][j][0] = 0; } for(int i = n; i >= 1; --i) for(int j = 1; j <= n; ++j) { nxt[i][j][1] = nxt[i + 1][j][1] + 1; if(tab[i][j] == 1) nxt[i][j][1] = 0; } Cnt(n); int ans = 0; for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) ans = max(ans, dod[i][j]); 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...