Submission #1056459

# Submission time Handle Problem Language Result Execution time Memory
1056459 2024-08-13T09:32:21 Z Tob Vision Program (IOI19_vision) C++14
0 / 100
8 ms 1752 KB
#include <bits/stdc++.h>

#include "vision.h"

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;

const int lg = 8;

vector <int> f(vector <int> v) {
	vector <int> v2;
	for (auto x : v) if (x != -1) v2.pb(x);
	return v2;
}

void add1(vector <int>& a, int ca) {
	for (int i = 0; i < lg; i++) {
		int y = add_and(f({a[i], ca}));
		a[i] = add_xor(f({a[i], ca}));
		ca = y;
	}
}

void add2(vector <int>& a, vector <int> b) {
	for (int i = 0, ca = -1; i < lg+1; i++) {
		vector <int> v1, v2;
		v1 = {a[i], b[i], ca};
		int x = add_xor(f(v1));
		if (ca == -1 && a[i] != -1 && b[i] != -1) ca = add_and({a[i], b[i]});
		v2 = f(v1);
		if (v2.size() < 2) ca = -1;
		else if (v2.size() == 2) ca = add_and(v2);
		else ca = add_or({add_and({v2[0],v2[1]}), add_and({v2[0],v2[2]}), add_and({v2[1],v2[2]})});
		a[i] = x;
	}
}

void construct_network(int h, int w, int k) {
	vector <int> pxh(h), pxw(w);
	vector <int> v, a, b, tmp;
	
	for (int i = 0; i < w; i++) v.pb(i);
	pxh[0] = add_xor(v);
	
	for (int i = 0; i < lg; i++) a.pb(-1);
	a[0] = pxh[0];
	tmp = {pxh[0]};
	
	for (int i = 1; i < h; i++) {
		v.clear(); for (int j = 0; j < w; j++) v.pb(i*w+j);
		v.pb(pxh[i-1]);
		pxh[i] = add_xor(v);
		add1(a, {pxh[i]});
		tmp.pb(pxh[i]);
	}
	
	v.clear();
	for (int i = 0; i < h; i++) v.pb(i*w);
	pxw[0] = add_xor(v);
	
	for (int i = 0; i < lg; i++) b.pb(-1);
	b[0] = pxw[0];
	tmp.pb(pxw[0]);
	
	for (int i = 1; i < w; i++) {
		v.clear(); for (int j = 0; j < h; j++) v.pb(j*w+i);
		v.pb(pxw[i-1]);
		pxw[i] = add_xor(v);
		add1(b, {pxw[i]});
		tmp.pb(pxw[i]);
	}
	
	int p[2];
	p[1] = add_or(tmp); p[0] = add_not(p[1]);
	
	a.pb(-1); b.pb(-1);
	add2(a, b);
	
	v.clear();
	for (int i = 0; i < lg+1; i++) {
		int B = ((k >> i) & 1);
		v.pb(add_xor(f({p[B], a[i]})));
	}
	add_not(add_or(v));
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB on inputs (0, 0), (0, 2), expected 1, but computed 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB on inputs (0, 0), (0, 2), expected 1, but computed 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB on inputs (0, 0), (0, 2), expected 1, but computed 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB on inputs (0, 0), (0, 2), expected 1, but computed 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB on inputs (0, 0), (0, 5), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB on inputs (0, 0), (3, 28), expected 1, but computed 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1752 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 1 ms 632 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Incorrect 1 ms 604 KB on inputs (0, 0), (0, 5), expected 0, but computed 1
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB on inputs (0, 0), (0, 2), expected 1, but computed 0
3 Halted 0 ms 0 KB -