Submission #433765

# Submission time Handle Problem Language Result Execution time Memory
433765 2021-06-20T10:32:54 Z MeGustaElArroz23 Vision Program (IOI19_vision) C++14
44 / 100
23 ms 8772 KB
#include "vision.h"
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef vector<vvii> vvvii;

int n;
int m;
vvi conexiones;

void debug(vi v){
	for (int x:v) cerr << x<<' ';
	cerr<<'\n';
}

bool sirve(pii x){
	if (x.first<0 or x.second<0 or x.first>=n or x.second>=m) return false;
	return true;
}

vi compressed_connections(vi v){
	vector<bool> todos(n*m,false);
	for (int x:v){
		for (int y:conexiones[x]) todos[y]=true;
	}
	vi res;
	for (int i=0;i<n*m;i++){
		if (todos[i]) res.push_back(i);
	}
	return res;
}

void nope_construct_network(int H, int W, int k) {
	n=H;
	m=W;
	conexiones=vvi(n*m);
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			for (int x=0;x<=k;x++){
				if (sirve(pii{i+x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j+(k-x));
				if (sirve(pii{i-x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j+(k-x));
				if (sirve(pii{i+x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j-(k-x));
				if (sirve(pii{i-x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j-(k-x));
			}
		}
	}
	for (int i=0;i<9;i++) debug(conexiones[i]);
	//debug(conexiones[0]);
	//debug(conexiones[1]);
	//debug(conexiones[5]);
	vi aux(n*m);
	for (int i=0;i<n*m;i++) aux[i]=i;
	int donde_true=add_or(aux);

	int maxpot=1;
	while (k%maxpot==0) maxpot*=2;


	vvi necesita(n*m);
	int pot=2;
	while (pot/2<n*m-1){
		vi v1;
		vi v2;
		for (int i=0;i<n*m;i++){
			if ((i/m+i%m)%maxpot<maxpot/2) continue;
			if (i%pot<pot/2) v1.push_back(i);
			else v2.push_back(i);
		}
		//debug(v1);
		//debug(v2);
		int a;
		if (v1.size()) a=add_or(v1);
		else a=add_not(donde_true);
		cerr << a << " : ";
		debug(v1);
		for (int i:v1){
			necesita[i].push_back(a);
		}
		//vi g=compressed_connections(v1);
		//debug(compressed_connections(v1));
		if (compressed_connections(v1).size()) a=add_or(compressed_connections(v1));
		else a=add_not(donde_true);
		cerr << a << " : ";
		debug(compressed_connections(v1));
		for (int i:v1){
			necesita[i].push_back(a);
		}
		if (v2.size()) a=add_or(v2);
		else a=add_not(donde_true);
		cerr << a << " : ";
		debug(v2);
		for (int i:v2){
			if (i%pot>=pot/2) necesita[i].push_back(a);
		}
		if (compressed_connections(v2).size()) a=add_or(compressed_connections(v2));
		else a=add_not(donde_true);
		cerr << a << " : ";
		debug(compressed_connections(v2));
		for (int i:v2){
			if (i%pot>=pot/2) necesita[i].push_back(a);
		}
		pot*=2;
	}
	for (int i=0;i<n*m;i++){
		cerr << i << ": ";
		debug(necesita[i]);
	}
	vi ac;
	
	for (int i=0;i<n*m;i++){
		if ((i/m+i%m)%maxpot<maxpot/2) continue;
		ac.push_back(add_and(necesita[i]));
	}
	//cerr<<"a";
	//debug(ac);
	add_or(ac);
}

void construct_network(int H, int W, int k){
	n=H;
	m=W;
	conexiones=vvi(n*m);
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			for (int x=0;x<=k;x++){
				if (sirve(pii{i+x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j+(k-x));
				if (sirve(pii{i-x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j+(k-x));
				if (sirve(pii{i+x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j-(k-x));
				if (sirve(pii{i-x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j-(k-x));
			}
		}
	}
	vi ac;
	for (int i=0;i<n*m;i++){
		if (conexiones[i].size()) ac.push_back(add_and(vi{add_and(vi{i}),add_or(conexiones[i])}));
	}
	add_or(ac);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 260 KB Output is correct
14 Correct 1 ms 288 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 260 KB Output is correct
14 Correct 1 ms 288 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 260 KB Output is correct
14 Correct 1 ms 288 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 6 ms 844 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 4 ms 588 KB Output is correct
34 Correct 6 ms 844 KB Output is correct
35 Correct 5 ms 800 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 260 KB Output is correct
14 Correct 1 ms 288 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 6 ms 844 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 4 ms 588 KB Output is correct
34 Correct 6 ms 844 KB Output is correct
35 Correct 5 ms 800 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 1 ms 288 KB Output is correct
38 Incorrect 18 ms 8772 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 288 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 292 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 10 ms 1224 KB Output is correct
4 Correct 23 ms 2784 KB Output is correct
5 Correct 17 ms 1988 KB Output is correct
6 Correct 8 ms 1096 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Incorrect 3 ms 1480 KB WA in grader: Too many instructions
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 3912 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 260 KB Output is correct
14 Correct 1 ms 288 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 6 ms 844 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 4 ms 588 KB Output is correct
34 Correct 6 ms 844 KB Output is correct
35 Correct 5 ms 800 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 1 ms 288 KB Output is correct
38 Incorrect 18 ms 8772 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -