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 "soccer.h"
#include <bits/stdc++.h>
using namespace std;
#define pf push_front
#define pb push_back
#define ll long long
#define vi vector<int>
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
vector<array<int,2>> v;
int n, a[10][10];
int recur(int pos){
if(pos==sz(v)){
int tot = 0;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
if(!a[i][j]) tot++;
return tot;
}
if(a[v[pos][0]][v[pos][1]]) return recur(pos+1);
int ans = 0;
for(int i = 0; i <= v[pos][0]; i++)
for(int j = 0; j <= v[pos][1]; j++)
a[i][j]++;
ans = max(ans, recur(pos+1));
for(int i = 0; i <= v[pos][0]; i++)
for(int j = 0; j <= v[pos][1]; j++)
a[i][j]--;
for(int i = 0; i <= v[pos][0]; i++)
for(int j = v[pos][1]; j < n; j++)
a[i][j]++;
ans = max(ans, recur(pos+1));
for(int i = 0; i <= v[pos][0]; i++)
for(int j = v[pos][1]; j < n; j++)
a[i][j]--;
for(int i = v[pos][0]; i < n; i++)
for(int j = 0; j <= v[pos][1]; j++)
a[i][j]++;
ans = max(ans, recur(pos+1));
for(int i = v[pos][0]; i < n; i++)
for(int j = 0; j <= v[pos][1]; j++)
a[i][j]--;
for(int i = v[pos][0]; i < n; i++)
for(int j = v[pos][1]; j < n; j++)
a[i][j]++;
ans = max(ans, recur(pos+1));
for(int i = v[pos][0]; i < n; i++)
for(int j = v[pos][1]; j < n; j++)
a[i][j]--;
return ans;
}
int biggest_stadium(int N, vector<vi> F)
{
n = N; v.clear();
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
if(F[i][j]) v.pb({i,j});
return recur(0);
}
# | 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... |