답안 #433743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433743 2021-06-20T10:12:36 Z MeGustaElArroz23 Vision Program (IOI19_vision) C++14
0 / 100
92 ms 14212 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 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<6;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=0;i<n*m;i++){
			if (i%pot<pot/2) 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=0;i<n*m;i++){
			if (i%pot<pot/2) 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=0;i<n*m;i++){
			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=0;i<n*m;i++){
			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);
}

# 결과 실행 시간 메모리 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 1 ms 296 KB Output is correct
6 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 296 KB Output is correct
6 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 296 KB Output is correct
6 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 296 KB Output is correct
6 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB on inputs (0, 1), (0, 4), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 15 ms 1820 KB Output is correct
4 Correct 28 ms 2400 KB Output is correct
5 Incorrect 24 ms 2116 KB on inputs (0, 0), (37, 28), expected 0, but computed 1
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 92 ms 14212 KB WA in grader: Too many inputs
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 296 KB Output is correct
6 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -