Submission #937281

#TimeUsernameProblemLanguageResultExecution timeMemory
937281Dan4LifeSoccer Stadium (IOI23_soccer)C++17
8 / 100
4549 ms596 KiB
#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) const int mxN = 10; vector<array<int,2>> v; int n, a[mxN][mxN]; bool vis[mxN][mxN]; int X[] = {1,-1,0,0}; int Y[] = {0,0,1,-1}; int recur(int i, int j){ if(i<0 or i>=n or j<0 or j>=n or vis[i][j] or !a[i][j]) return 0; vis[i][j] = 1; int ans = 1; for(int k = 0; k < 4; k++) ans+=recur(i+X[k],j+Y[k]); return ans; } bool complete(int x, int y, int x2, int y2){ for(int i = x; i <= x2; i++) for(int j = y; j <= y2; j++) if(a[i][j]==0) return 0; return 1; } bool cantgo(array<int,2> A, array<int,2> B){ int x1 = A[0], y1 = A[1]; int x2 = B[0], y2 = B[1]; if(complete(x1,y1,x2,y1) and complete (x2,y1,x2,y2)) return 0; if(complete(x1,y1,x1,y2) and complete (x1,y2,x2,y2)) return 0; return 1; } 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}); int ans = 0; for(int mask = 1; mask < (1<<sz(v)); mask++){ vector<array<int,2>> w; w.clear(); for(int i = 0; i < sz(v); i++) if(mask>>i&1) w.pb(v[i]); for(int i = 0; i < sz(w); i++) a[w[i][0]][w[i][1]]=1; int bad = 0; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) vis[i][j] = 0; if(recur(w[0][0],w[0][1])!=sz(w)) bad=1; for(int i = 0; i < sz(w) and !bad; i++) for(int j = 0; j < sz(w) and !bad; j++) if(cantgo(w[i],w[j])) bad=1; if(!bad) ans = max(ans, sz(w)); for(int i = 0; i < sz(w); i++) a[w[i][0]][w[i][1]]=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...