# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1059178 | hasan2006 | Soccer Stadium (IOI23_soccer) | C++17 | 172 ms | 55312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;
#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"
const int N = 2e3 + 9 , mod = 1e9 + 7;
ll b[N] , dp[N] , c[N] , d[N] , us[N][N] ;
vector<vector<int>>a;
void dfs(int i , int j , int n) {
if(!us[i][j])
us[i][j] = 1;
if(j && !a[i][j - 1] && !us[i][j - 1])
dfs(i , j - 1 , n);
if(i && !a[i - 1][j] && !us[i - 1][j])
dfs(i - 1, j , n);
if(j + 1 < n && !a[i][j + 1] && !us[i][j + 1])
dfs(i , j + 1 , n);
if(i + 1 < n && !a[i + 1][j] && !us[i + 1][j])
dfs(i + 1, j , n);
}
int biggest_stadium(int n , vector<vector<int>>a) {
ll i , j , l, r , s = 0 , f = 0 , x , y , k , m ;
::a = a;
y = 0;
for(i = 0; i < n; i++) {
s = 0;
for(j = 0; j < n; j++) {
f += 1 - a[i][j];
if(a[i][j] == 0 && s == 0)
s = 1;
else if(a[i][j] == 1 && s == 1)
s = 2;
else if(a[i][j] == 0 && s == 2)
s = -1;
}
if(s == -1)
return f - 1;
}
for(i = 0; i < n; i++) {
s = 0;
for(j = 0; j < n; j++) {
if(a[j][i] == 0 && s == 0)
s = 1;
else if(a[j][i] == 1 && s == 1)
s = 2;
else if(a[j][i] == 0 && s == 2)
s = -1;
}
if(s == -1)
return f - 1;
}
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
if(!us[i][j] && !a[i][j])
dfs(i , j , n) , y++;
if(y <= 1)
return f;
else
return f - 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |