Submission #1010399

#TimeUsernameProblemLanguageResultExecution timeMemory
1010399thinknoexitSoccer Stadium (IOI23_soccer)C++17
35.50 / 100
262 ms71508 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2020; int n; int f[N][N], qs[N][N]; int l[N], r[N]; // check if all empty cell are regular stadium bool all_can() { for (int i = 1;i <= n;i++) { for (int j = 1;j <= n + 1;j++) { if (f[i][j - 1] != f[i][j]) { if (!l[i]) l[i] = j; else if (!r[i]) r[i] = j - 1; else return 0; } } } for (int j = 1;j <= n;j++) { int cnt = 0; for (int i = 1;i <= n;i++) { cnt += f[i - 1][j] != f[i][j]; } if (cnt > 2) return 0; } for (int i = 1;i <= n;i++) { if (l[i] == 0) continue; for (int j = 1;j <= n;j++) { if (l[j] == 0) continue; bool ch = (l[i] <= l[j] && r[j] <= r[i]) || (l[j] <= l[i] && r[i] <= r[j]); if (!ch) return 0; } } return 1; } int mx = 0; void play(int st) { if (st == n + 1) { bool can = 1; int cnt = 0; { int cnt = 0; for (int i = 1;i <= n;i++) { cnt += (l[i] == 0) != (l[i - 1] == 0); } if (cnt > 2) return; } if (l[1] && l[2] && l[3]) { for (int i = 2;i < n;i++) { if (l[i - 1] < l[i] && l[i] > l[i + 1]) return; if (r[i - 1] > r[i] && r[i] < r[i + 1]) return; } } for (int i = 1;i <= n;i++) { if (l[i] == 0) continue; cnt += r[i] - l[i] + 1; for (int j = 1;j <= n;j++) { if (l[j] == 0) continue; bool ch = (l[i] <= l[j] && r[j] <= r[i]) || (l[j] <= l[i] && r[i] <= r[j]); if (!ch) can = 0; } } if (can) mx = max(mx, cnt); return; } l[st] = r[st] = 0; play(st + 1); for (int i = 1;i <= n;i++) { for (int j = i;j <= n;j++) { l[st] = i, r[st] = j; if (qs[st][j] - qs[st][i - 1] == 0) play(st + 1); } } } int biggest_stadium(int NN, vector<vector<int>> F) { n = NN; int empty_cell = 0; for (int i = 1;i <= n;i++) { f[0][i] = f[n + 1][i] = f[i][0] = f[i][n + 1] = 1; for (int j = 1;j <= n;j++) { f[i][j] = F[i - 1][j - 1]; qs[i][j] = qs[i][j - 1] + f[i][j]; empty_cell += f[i][j] == 0; } } if (all_can()) return empty_cell; if (empty_cell == n * n - 1) { int mx = 0; for (int i = 1;i <= n && !mx;i++) { for (int j = 1;j <= n && !mx;j++) { if (f[i][j]) { mx = max(mx, (i - 1) * n + (j - 1) * n - (i - 1) * (j - 1)); mx = max(mx, (n - i) * n + (j - 1) * n - (n - i) * (j - 1)); mx = max(mx, (i - 1) * n + (n - j) * n - (i - 1) * (n - j)); mx = max(mx, (n - i) * n + (n - j) * n - (n - i) * (n - j)); } } } return mx; } if (n <= 3) play(1); return mx; }
#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...