Submission #778654

# Submission time Handle Problem Language Result Execution time Memory
778654 2023-07-10T14:17:51 Z andrej246 Vision Program (IOI19_vision) C++14
12 / 100
64 ms 17892 KB
#include "vision.h"
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,N) for(long long i = 0; (i) < (N); (i)++)
#define FORS(i,v,N) for(long long i = v; (i) < (N); (i)++)
#define FORI(i,v,N,inc) for(long long i = v; (i) < (N); (i)+=(inc))

#define NL '\n'
#define EL std::cout << NL

#define PRINTV(v) for(auto a:(v)) {std::cout << a << " ";};EL
#define PRINTVV(v) for(auto a:(v)) {PRINTV(a);}

#define print_vals(v)

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VLL;
typedef pair<ll,ll> PL;
typedef vector<PL> VPL;
typedef vector<VPL> VVPL;

void construct_network(int H, int W, int K) {
	std::vector<int> Ns;
	int z,o;
	if (H*W > 3) {
		z = add_and({0,1,2});
		o = add_not(z);
	} else {
        o = add_and({0,1});
		z = add_not(o);
	}
    vector<vector<int>> xinter0(8);
    vector<vector<int>> xinter1(8);
	vector<vector<int>> yinter0(8);
    vector<vector<int>> yinter1(8);
	int pow = 1;
	FOR(n,8) {
	    FOR(i,H*W) {
            if (((i%W)/pow) % 2) {
				xinter1[n].push_back(i);
			} else {
				xinter0[n].push_back(i);
			}
			if (((i/W)/pow) % 2) {
				yinter1[n].push_back(i);
			} else {
				yinter0[n].push_back(i);
			}
		}
		pow *= 2;
	}
	vector<vector<vector<int>>> xinter11(8,vector<vector<int>>(8));
	vector<vector<vector<int>>> yinter11(8,vector<vector<int>>(8));
	vector<vector<vector<int>>> xinter10(8,vector<vector<int>>(8));
	vector<vector<vector<int>>> yinter10(8,vector<vector<int>>(8));
	pow = 1;
	FOR(m,8) {
		FOR(n,8) {
			for(int i : xinter1[n]) {
				if (((i%W)/pow) % 2) {
					xinter11[m][n].push_back(i);
				}
			}
			for(int i : xinter0[n]) {
				if (((i%W)/pow) % 2) {
					xinter10[m][n].push_back(i);
				}
			}
		}
		pow *= 2;
	}
	pow = 1;
	FOR(m,8) {
		FOR(n,8) {
			for(int i : yinter1[n]) {
				if (((i/W)/pow) % 2) {
					yinter11[m][n].push_back(i);
				}
			}
			for(int i : yinter0[n]) {
				if (((i/W)/pow) % 2) {
					yinter10[m][n].push_back(i);
				}
			}
		}
		pow *= 2;
	}
	FOR(m,8) {
		FOR(n,8) {
			if (xinter11[m][n].size() == 0) {
				xinter11[m][n] = {z};
			}
			if (yinter11[m][n].size() == 0) {
				yinter11[m][n] = {z};
			}
			if (xinter10[m][n].size() == 0) {
				xinter10[m][n] = {z};
			}
			if (yinter10[m][n].size() == 0) {
				yinter10[m][n] = {z};
			}
		}
	}
	//PRINTV(xinter0[6]); EL;
	//PRINTVV(xinter1); EL;
	//PRINTVV(yinter0); EL;
	//PRINTVV(yinter1); EL;
	vector<int> x1(8);
	vector<int> x2(8);
	vector<int> y1(8);
	vector<int> y2(8);
	vector<int> xbreakbits;
	vector<int> ybreakbits;
	for(int i = 7; i >= 0; i--) {
		vector<int> i0 = xinter0[i];
		vector<int> i1 = xinter1[i];
		if (i0.size() == 0) i0 = {z};
		if (i1.size() == 0) i1 = {z};
		int is_diff = add_and({add_xor(i0),add_xor(i1)});
		int or_bit = add_or(i1);
		if (i == 7) {
			xbreakbits.push_back(add_or({is_diff}));
		} else {
			xbreakbits.push_back(add_and({add_not(add_or(xbreakbits)),is_diff}));
		}
		vector<int> disc_listA;
		vector<int> disc_listB;
		for(int j = 7; j >= i; j--) {
			disc_listA.push_back(add_and({add_or(xinter10[i][j]),xbreakbits[7-j]}));
			disc_listB.push_back(add_and({add_or(xinter11[i][j]),xbreakbits[7-j]}));
		}
		int discA = add_or(disc_listA);
		int discB = add_or(disc_listB);
		//vector<int> db = {is_diff,discA,discB};
		//print_vals(db);
		x1[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discA})});
		x2[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discB})});
	}
	for(int i = 7; i >= 0; i--) {
		vector<int> i0 = yinter0[i];
		vector<int> i1 = yinter1[i];
		if (i0.size() == 0) i0 = {z};
		if (i1.size() == 0) i1 = {z};
		int is_diff = add_and({add_xor(i0),add_xor(i1)});
		int or_bit = add_or(i1);
		if (i == 7) {
			ybreakbits.push_back(add_or({is_diff}));
		} else {
			ybreakbits.push_back(add_and({add_not(add_or(ybreakbits)),is_diff}));
		}
		vector<int> disc_listA;
		vector<int> disc_listB;
		for(int j = 7; j >= i; j--) {
			disc_listA.push_back(add_and({add_or(yinter10[i][j]),ybreakbits[7-j]}));
			disc_listB.push_back(add_and({add_or(yinter11[i][j]),ybreakbits[7-j]}));
		}
		int discA = add_or(disc_listA);
		int discB = add_or(disc_listB);
		//vector<int> db = {is_diff,discA,discB};
		//print_vals(db);
		y1[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discA})});
		y2[i] = add_or({add_and({or_bit,add_not(is_diff)}),add_and({is_diff,discB})});
	}
	print_vals(x1);
	print_vals(x2);
	print_vals(y1);
	print_vals(y2);
	vector<int> rx1(9);
	vector<int> ry1(9);
	vector<int> dx(9);
	vector<int> dy(9);
	FOR(i,8) {
		rx1[i] = add_not(x1[i]);
		ry1[i] = add_not(y1[i]);
	}
	int c1 = z;
	FOR(i,8) {
		rx1[i] = add_xor({c1,o,rx1[i]});
        c1 = add_or({c1,rx1[i]});
	}
	c1 = z;
	FOR(i,8) {
		ry1[i] = add_xor({c1,o,ry1[i]});
        c1 = add_or({c1,ry1[i]});
	}
	rx1[8] = ry1[8] = o;
	int c = z;
	FOR(i,8) {
        dx[i] = add_xor({rx1[i],x2[i],c});
		c = add_or({add_and({rx1[i],x2[i]}),add_and({rx1[i],c}),add_and({c,x2[i]})});
	}
	dx[8] = add_xor({c,o});
	c = z;
	FOR(i,8) {
        dy[i] = add_xor({ry1[i],y2[i],c});
		c = add_or({add_and({ry1[i],y2[i]}),add_and({ry1[i],c}),add_and({c,y2[i]})});
	}
	dy[8] = add_xor({c,o});
	print_vals(rx1);
	print_vals(ry1);
	print_vals(dx);
	print_vals(dy);
	c = z;
	vector<int> dist(9);
	FOR(i,9) {
        dist[i] = add_xor({dx[i],dy[i],c});
		c = add_or({add_and({dx[i],dy[i]}),add_and({dx[i],c}),add_and({c,dy[i]})});
	}
	print_vals(dist);
	vector<int> kdist;
	vector<int> pos,pos2;
	while(K) {
		kdist.push_back(K%2);
		K /= 2;
	}
	//PRINTV(kdist);
	FOR(i,8) {
        if (i < (int)kdist.size() && kdist[i]) {
			pos.push_back(dist[i]);
		} else {
            pos2.push_back(dist[i]);
		}
	}
	if (pos.size() == 0) {
		pos = {z};
	} else if (pos2.size() == 0) {
		pos2 = {z};
	}
	print_vals(pos);
	print_vals(pos2);
	add_and({add_and(pos),add_not(add_or(pos2))});
	
	//print_vals(xbreakbits);
	return;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 2 ms 432 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 2 ms 424 KB Output is correct
14 Correct 2 ms 428 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 424 KB Output is correct
19 Correct 2 ms 428 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 20 ms 2636 KB Output is correct
4 Correct 18 ms 2684 KB Output is correct
5 Correct 17 ms 2596 KB Output is correct
6 Correct 17 ms 2668 KB Output is correct
7 Correct 17 ms 2676 KB Output is correct
8 Correct 43 ms 5252 KB Output is correct
9 Correct 34 ms 5216 KB Output is correct
10 Correct 37 ms 5280 KB Output is correct
11 Correct 34 ms 5224 KB Output is correct
12 Correct 35 ms 5200 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 2 ms 428 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Incorrect 33 ms 11208 KB WA in grader: Too many inputs
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 17892 KB WA in grader: Too many inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB on inputs (0, 1), (0, 2), expected 1, but computed 0
2 Halted 0 ms 0 KB -