Submission #1078525

#TimeUsernameProblemLanguageResultExecution timeMemory
1078525beaconmcSoccer Stadium (IOI23_soccer)C++17
12 / 100
4576 ms125780 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 prefrow[2001][2001]; ll prefcol[2001][2001]; ll grid[2001][2001]; bool checkrow(ll a, ll b, ll row){ if (a>b) swap(a,b); return (prefrow[row][b] - prefrow[row][a] + grid[row][a] == 0); } bool checkcol(ll a, ll b, ll col){ if (a>b) swap(a,b); return (prefcol[b][col] - prefcol[a][col] + grid[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){ grid[i][j] = F[i][j]; ans -= F[i][j]; } } FOR(i,0,N){ prefrow[i][0] = F[i][0]; FOR(j,1,N){ prefrow[i][j] = prefrow[i][j-1] + F[i][j]; } } FOR(j,0,N){ prefcol[0][j] = F[0][j]; FOR(i,1,N){ prefcol[i][j] = prefcol[i-1][j] + F[i][j]; } } FOR(i,0,N){ FOR(j,0,N){ FOR(k,0,N){ FOR(l,0,N){ if (grid[i][j]==1 || grid[k][l] == 1) continue; bool check1 = (checkrow(l, j, i) && checkcol(k, i, l)); bool check2 = (checkrow(l, j, k) && checkcol(k, i, j)); if (!check1 && !check2){ // cout << i << " " << j << " " << k << " " << l << endl; // cout << checkrow(0,3,0) << endl; // cout << checkcol(4,0,3) << endl; 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...