Submission #1079645

#TimeUsernameProblemLanguageResultExecution timeMemory
1079645beaconmcSoccer Stadium (IOI23_soccer)C++17
25 / 100
1122 ms243344 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) ll prefrow2[2001][2001]; ll prefcol2[2001][2001]; ll grid2[2001][2001]; bool checkrow2(ll a, ll b, ll row){ if (a>b) swap(a,b); return (prefrow2[row][b] - prefrow2[row][a] + grid2[row][a] == 0); } bool checkcol2(ll a, ll b, ll col){ if (a>b) swap(a,b); return (prefcol2[b][col] - prefcol2[a][col] + grid2[a][col] == 0); } int biggest_stadium(int N, std::vector<std::vector<int>> F) { ll ans = N*N; FOR(i,0,N){ FOR(j,0,N){ grid2[i][j] = F[i][j]; ans -= F[i][j]; } } FOR(i,0,N){ prefrow2[i][0] = F[i][0]; FOR(j,1,N){ prefrow2[i][j] = prefrow2[i][j-1] + F[i][j]; } } FOR(j,0,N){ prefcol2[0][j] = F[0][j]; FOR(i,1,N){ prefcol2[i][j] = prefcol2[i-1][j] + F[i][j]; } } vector<vector<ll>> special; FOR(i,0,N){ FOR(j,0,N){ vector<vector<ll>> sus = {{i-1,j}, {i+1,j}, {i,j-1}, {i,j+1}}; if (grid2[i][j] != 1){ bool flag = 0; for (auto&k : sus){ if (0<=k[0] && k[0]<N && 0<=k[1] && k[1]<N){ if (grid2[k[0]][k[1]]==1) flag = 1; } } if (flag==1 || i==0 || i==N-1 || j==0 || j==N-1) special.push_back({i,j}); } } } for (auto&X : special){ for (auto&Y : special){ ll i = X[0], j = X[1], k = Y[0], l= Y[1]; if (grid2[i][j]==1 || grid2[k][l] == 1) continue; bool check1 = (checkrow2(l, j, i) && checkcol2(k, i, l)); bool check2 = (checkrow2(l, j, k) && checkcol2(k, i, j)); if (!check1 && !check2) return 0; } } 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...