답안 #433768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433768 2021-06-20T10:35:14 Z MeGustaElArroz23 Vision Program (IOI19_vision) C++14
8 / 100
98 ms 51656 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 normal_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);
}

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<=0;i++){
		if (conexiones[i].size()) ac.push_back(add_and(vi{add_and(vi{i}),add_or(conexiones[i])}));
	}
	add_or(ac);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 3 ms 972 KB Output is correct
5 Correct 2 ms 716 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 7 ms 2764 KB Output is correct
10 Correct 6 ms 1868 KB Output is correct
11 Correct 4 ms 844 KB Output is correct
12 Correct 3 ms 420 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 204 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 6 ms 1612 KB Output is correct
21 Correct 38 ms 15940 KB Output is correct
22 Correct 21 ms 4804 KB Output is correct
23 Correct 18 ms 776 KB Output is correct
24 Correct 5 ms 1612 KB Output is correct
25 Correct 29 ms 10004 KB Output is correct
26 Correct 17 ms 780 KB Output is correct
27 Correct 10 ms 3076 KB Output is correct
28 Correct 98 ms 51656 KB Output is correct
29 Correct 79 ms 32860 KB Output is correct
30 Correct 44 ms 5416 KB Output is correct
31 Correct 42 ms 1228 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 3020 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -