Submission #937281

# Submission time Handle Problem Language Result Execution time Memory
937281 2024-03-03T18:16:00 Z Dan4Life Soccer Stadium (IOI23_soccer) C++17
8 / 100
4500 ms 596 KB
#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 time Memory Grader output
1 Correct 2815 ms 408 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Incorrect 36 ms 344 KB wrong
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 596 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 1 ms 348 KB ok
6 Correct 1 ms 436 KB ok
7 Correct 1 ms 432 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 1 ms 432 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2815 ms 408 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 596 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 1 ms 436 KB ok
8 Correct 1 ms 432 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 1 ms 432 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 1 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Partially correct 15 ms 436 KB partial
16 Partially correct 4 ms 348 KB partial
17 Partially correct 0 ms 348 KB partial
18 Execution timed out 4549 ms 348 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2815 ms 408 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Incorrect 36 ms 344 KB wrong
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2815 ms 408 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Incorrect 36 ms 344 KB wrong
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2815 ms 408 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Incorrect 36 ms 344 KB wrong
5 Halted 0 ms 0 KB -