Submission #1056551

# Submission time Handle Problem Language Result Execution time Memory
1056551 2024-08-13T10:00:24 Z Tob Vision Program (IOI19_vision) C++14
100 / 100
6 ms 1764 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;
int p[2];

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;
		if (a[i] != -1) y = add_and({a[i], ca});
		else y = p[0];
		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);
		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);
		tmp.pb(pxw[i]);
	}
	
	p[1] = add_or(tmp); p[0] = add_not(p[1]);
	
	for (int i = 1; i < h; i++) add1(a, pxh[i]);
	for (int i = 1; i < w; i++) add1(b, pxw[i]);
	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 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 392 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 392 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 436 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 436 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 392 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 436 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 436 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 3 ms 860 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 528 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 792 KB Output is correct
45 Correct 2 ms 904 KB Output is correct
46 Correct 2 ms 860 KB Output is correct
47 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 688 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 3 ms 984 KB Output is correct
21 Correct 6 ms 984 KB Output is correct
22 Correct 3 ms 1224 KB Output is correct
23 Correct 3 ms 1212 KB Output is correct
24 Correct 3 ms 984 KB Output is correct
25 Correct 3 ms 984 KB Output is correct
26 Correct 4 ms 984 KB Output is correct
27 Correct 6 ms 1764 KB Output is correct
28 Correct 6 ms 1748 KB Output is correct
29 Correct 5 ms 1752 KB Output is correct
30 Correct 6 ms 1752 KB Output is correct
31 Correct 5 ms 1752 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1508 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 672 KB Output is correct
4 Correct 1 ms 792 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 3 ms 984 KB Output is correct
8 Correct 4 ms 984 KB Output is correct
9 Correct 5 ms 1752 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 392 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 436 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 436 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 3 ms 860 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 528 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 792 KB Output is correct
45 Correct 2 ms 904 KB Output is correct
46 Correct 2 ms 860 KB Output is correct
47 Correct 2 ms 860 KB Output is correct
48 Correct 1 ms 600 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 1 ms 604 KB Output is correct
52 Correct 1 ms 688 KB Output is correct
53 Correct 1 ms 604 KB Output is correct
54 Correct 1 ms 604 KB Output is correct
55 Correct 1 ms 604 KB Output is correct
56 Correct 1 ms 604 KB Output is correct
57 Correct 1 ms 604 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
59 Correct 1 ms 604 KB Output is correct
60 Correct 1 ms 604 KB Output is correct
61 Correct 2 ms 604 KB Output is correct
62 Correct 2 ms 604 KB Output is correct
63 Correct 1 ms 604 KB Output is correct
64 Correct 1 ms 604 KB Output is correct
65 Correct 1 ms 600 KB Output is correct
66 Correct 1 ms 600 KB Output is correct
67 Correct 1 ms 604 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 1 ms 604 KB Output is correct
73 Correct 1 ms 604 KB Output is correct
74 Correct 1 ms 604 KB Output is correct
75 Correct 1 ms 604 KB Output is correct
76 Correct 1 ms 604 KB Output is correct
77 Correct 1 ms 600 KB Output is correct
78 Correct 2 ms 604 KB Output is correct
79 Correct 1 ms 604 KB Output is correct
80 Correct 2 ms 604 KB Output is correct
81 Correct 1 ms 600 KB Output is correct
82 Correct 1 ms 604 KB Output is correct
83 Correct 1 ms 604 KB Output is correct
84 Correct 1 ms 604 KB Output is correct
85 Correct 1 ms 604 KB Output is correct
86 Correct 1 ms 604 KB Output is correct
87 Correct 1 ms 604 KB Output is correct
88 Correct 1 ms 604 KB Output is correct
89 Correct 3 ms 984 KB Output is correct
90 Correct 6 ms 984 KB Output is correct
91 Correct 3 ms 1224 KB Output is correct
92 Correct 3 ms 1212 KB Output is correct
93 Correct 3 ms 984 KB Output is correct
94 Correct 3 ms 984 KB Output is correct
95 Correct 4 ms 984 KB Output is correct
96 Correct 6 ms 1764 KB Output is correct
97 Correct 6 ms 1748 KB Output is correct
98 Correct 5 ms 1752 KB Output is correct
99 Correct 6 ms 1752 KB Output is correct
100 Correct 5 ms 1752 KB Output is correct
101 Correct 0 ms 348 KB Output is correct
102 Correct 0 ms 348 KB Output is correct
103 Correct 6 ms 1508 KB Output is correct
104 Correct 1 ms 348 KB Output is correct
105 Correct 1 ms 672 KB Output is correct
106 Correct 1 ms 792 KB Output is correct
107 Correct 1 ms 604 KB Output is correct
108 Correct 1 ms 604 KB Output is correct
109 Correct 3 ms 984 KB Output is correct
110 Correct 4 ms 984 KB Output is correct
111 Correct 5 ms 1752 KB Output is correct
112 Correct 0 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 5 ms 1752 KB Output is correct
115 Correct 1 ms 608 KB Output is correct
116 Correct 1 ms 604 KB Output is correct
117 Correct 3 ms 992 KB Output is correct
118 Correct 4 ms 984 KB Output is correct
119 Correct 5 ms 1624 KB Output is correct
120 Correct 6 ms 1752 KB Output is correct
121 Correct 6 ms 1752 KB Output is correct
122 Correct 6 ms 1504 KB Output is correct
123 Correct 6 ms 1752 KB Output is correct
124 Correct 5 ms 1580 KB Output is correct
125 Correct 6 ms 1752 KB Output is correct
126 Correct 6 ms 1752 KB Output is correct
127 Correct 5 ms 1752 KB Output is correct
128 Correct 6 ms 1748 KB Output is correct