Submission #621061

# Submission time Handle Problem Language Result Execution time Memory
621061 2022-08-03T11:37:26 Z beaconmc Vision Program (IOI19_vision) C++14
0 / 100
47 ms 4776 KB
#include "vision.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef int ll;
using namespace std;
using namespace __gnu_pbds;

#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll h,w,k;

vector<int> hashh(vector<int> a){
	return {a[0]+a[1], a[1]-a[0]};
}

int unhashh(vector<int> a){
	vector<int> temp =  {(a[0]-a[1])/2, (a[0]+a[1])/2};

	return w*temp[0]+temp[1];
}

// vector<int> arr = {1,1};

// int add_and(vector<int> a){
// 	FOR(i,0,a.size()){
// 		a[i] = arr[a[i]];
// 	}
// 	FOR(i,1,a.size()){
// 		a[0] &= a[i];
// 	}
// 	arr.push_back(a[0]);
// 	return arr.size()-1;
// }
// int add_xor(vector<int> a){
// 	FOR(i,0,a.size()){
// 		a[i] = arr[a[i]];
// 	}

// 	FOR(i,1,a.size()){
// 		a[0] ^= a[i];
// 	}
// 	arr.push_back(a[0]);
// 	return arr.size()-1;
// }
// int add_or(vector<int> a){
// 	FOR(i,0,a.size()){
// 		a[i] = arr[a[i]];
// 	}
// 	FOR(i,1,a.size()){
// 		a[0] |= a[i];
// 	}
// 	arr.push_back(a[0]);
// 	return arr.size()-1;
// }
// int add_not(int a){
// 	if(arr[a]) arr.push_back(0);
// 	else arr.push_back(1);
// 	return arr.size()-1;
// }



void construct_network(int H, int W, int K) {
	h=H; w=W; k=K;

	set<ll> x;
	set<ll> y;
	unordered_map<ll, vector<ll>> xs;
	unordered_map<ll, vector<ll>> ys;
	unordered_map<ll, ll> xx;
	unordered_map<ll, ll> yy;


	vector<vector<ll>> stuff;
	FOR(i,0,h){
		FOR(j,0,w){
			stuff.push_back(hashh({i,j}));
		}
	}

	for (auto&i : stuff){
		x.insert(i[0]);
		y.insert(i[1]);
		xs[i[0]].push_back(unhashh(i));
		ys[i[1]].push_back(unhashh(i));
	}
	for (auto&i : xs){
		xx[i.first] = add_xor(i.second);
	}
	for (auto&i : ys){
		yy[i.first] = add_xor(i.second);
	}

	vector<int> fx, fy, sx, sy;

	for (auto&i : x){

		vector<int> fir,sec;
		for (auto&j : y){
			if (j == i) fir.push_back(yy[j]);
			else if (j == i-k || j == i+k) sec.push_back(yy[j]);
		}
		if (!(fir.size() && sec.size())){
			fx.push_back(add_or({0,0}));
			continue;
		}

		fx.push_back(add_and({add_or(fir),add_or(sec)}));

	}
	for (auto&i : y){
		vector<int> fir,sec;
		for (auto&j : x){

			if (j == i) fir.push_back(xx[j]);
			else if (j < i-k || j > i+k) sec.push_back(xx[j]);
		}

		if (!(fir.size() && sec.size())){

			fy.push_back(add_or({0,0}));
			continue;
		}

		fy.push_back(add_and({add_or(fir),add_or(sec)}));
	}


	for (auto&i : y){
		vector<int> fir,sec;
		for (auto&j : x){
			if (j == i) fir.push_back(xx[j]);
			else if (j == i-k || j == i+k) sec.push_back(xx[j]);
		}
		if (!(fir.size() && sec.size())){
			sy.push_back(add_or({0,0}));
			continue;
		}
		sy.push_back(add_and({add_or(fir),add_or(sec)}));
	}

	for (auto&i : x){
		vector<int> fir,sec;
		for (auto&j : y){
			if (j == i) fir.push_back(yy[j]);
			else if (j < i-k || j > i+k) sec.push_back(yy[j]);
		}
		if (!(fir.size() && sec.size())){
			sx.push_back(add_or({0,0}));
			continue;
		}
		sx.push_back(add_and({add_or(fir),add_or(sec)}));
	}


	ll a,b,c,d;
	a = add_or(fx);
	b = add_not(add_or(fy));
	c = add_or(sy);
	d = add_not(add_or(sx));


	ll aa = add_and({a,b});
	ll bb = add_and({c,d});

	add_or({aa,bb});

}

// int main(){
// 	construct_network(1,2, 1);
// 	for (auto&i : arr) cout << i << " ";
// }


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1092 KB Output is correct
2 Incorrect 5 ms 724 KB on inputs (0, 0), (0, 99), expected 1, but computed 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 4776 KB on inputs (103, 46), (135, 15), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -