Submission #154706

# Submission time Handle Problem Language Result Execution time Memory
154706 2019-09-23T17:04:42 Z MetB Vision Program (IOI19_vision) C++14
100 / 100
43 ms 4476 KB
#include "vision.h"
#include <iostream>

using namespace std;

int a[100000], k, t, H, W, K;

struct data {

	struct segment {
	int l, r;
	} prim, weak, sec;

	int prim_res, sec_res, zero, shortcut, l, r;
} diag, antid;

vector <int> tie (int a, int b)
{
	vector <int> c;

	c.push_back (a);
	c.push_back (b);

	return c;
}

void process (data& diag, bool rev, int H, int W, int K) {
	vector <int> v;

	diag.l = t;

	for (int i = (rev ? 0 : -H + 1); i < (rev ? W + H - 1 : W); i++) {
		v.clear ();
		for (int j = 0; j < H; j++) {
			int ji = (rev ? i - j : j + i);
			if (0 <= ji && ji < W) {
				v.push_back (j * W + ji);
			}
		}

		t++;
		add_xor (v);
	}

	diag.r = t;
	diag.prim.l = t;
	for (int i = diag.l; i < diag.r; i++) {
		if (i - K >= diag.l) {
			add_and (tie (i - K, i));
			t++;
		}
	}

	diag.prim.r = t;
	v.clear ();
	for (int i = diag.l; i < diag.r; i++) {
		v.push_back (i);
	}

	diag.shortcut = t + 1;
	add_or (v);
	add_not (t);
	t += 2;

	diag.zero = t;
	add_xor (tie (0, 0));
	t++;

	diag.weak.l = t;
	for (int i = diag.l; i < diag.r; i++) {
		v.clear ();
		for (int j = max (diag.l, i - K); j < min (diag.r, i + K + 1); j++) {
			if (j != i) v.push_back (j);
			else v.push_back (diag.zero);
		}
		add_or (v);
		t++;
	}
	diag.weak.r = t;

	diag.sec.l = t;
	for (int i = 0; i < diag.r - diag.l; i++) {
		add_and (tie (diag.l + i, diag.weak.l + i));
		t++;
	}
	diag.sec.r = t;

	v.clear ();
	diag.prim_res = t;
	for (int i = diag.prim.l; i < diag.prim.r; i++) {
		v.push_back (i);
	}
	add_or (v);
	t++;

	v.clear ();
	diag.sec_res = t;
	for (int i = diag.sec.l; i < diag.sec.r; i++) {
		v.push_back (i);
	}
	v.push_back (diag.shortcut);
	add_or (v);
	t++;

}

void construct_network (int H, int W, int K) {
	t = H * W;

	process (diag, false, H, W, K);
	process (antid, true, H, W, K);

	add_and (tie (diag.prim_res, antid.sec_res));
	int primsec = t;
	t++;

	add_and (tie (antid.prim_res, diag.sec_res));
	int secprim = t;
	t++;

	add_or (tie (primsec, secprim));
	t++;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 476 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 476 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 400 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 476 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 400 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 296 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 4 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 476 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 400 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 296 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 4 ms 404 KB Output is correct
38 Correct 8 ms 1016 KB Output is correct
39 Correct 4 ms 504 KB Output is correct
40 Correct 4 ms 504 KB Output is correct
41 Correct 5 ms 504 KB Output is correct
42 Correct 8 ms 888 KB Output is correct
43 Correct 5 ms 632 KB Output is correct
44 Correct 8 ms 888 KB Output is correct
45 Correct 11 ms 1144 KB Output is correct
46 Correct 13 ms 1272 KB Output is correct
47 Correct 13 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 9 ms 888 KB Output is correct
3 Correct 9 ms 936 KB Output is correct
4 Correct 11 ms 1016 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 7 ms 760 KB Output is correct
7 Correct 10 ms 1016 KB Output is correct
8 Correct 10 ms 1016 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 6 ms 760 KB Output is correct
11 Correct 9 ms 888 KB Output is correct
12 Correct 9 ms 888 KB Output is correct
13 Correct 10 ms 1016 KB Output is correct
14 Correct 10 ms 1016 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 6 ms 760 KB Output is correct
17 Correct 9 ms 888 KB Output is correct
18 Correct 9 ms 972 KB Output is correct
19 Correct 10 ms 1016 KB Output is correct
20 Correct 10 ms 1016 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 6 ms 760 KB Output is correct
6 Correct 6 ms 760 KB Output is correct
7 Correct 6 ms 760 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 7 ms 760 KB Output is correct
10 Correct 9 ms 888 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 10 ms 1016 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 2 ms 1016 KB Output is correct
16 Correct 10 ms 1016 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 8 ms 888 KB Output is correct
19 Correct 10 ms 1016 KB Output is correct
20 Correct 8 ms 888 KB Output is correct
21 Correct 18 ms 1912 KB Output is correct
22 Correct 23 ms 2424 KB Output is correct
23 Correct 25 ms 2552 KB Output is correct
24 Correct 8 ms 1016 KB Output is correct
25 Correct 21 ms 2316 KB Output is correct
26 Correct 25 ms 2680 KB Output is correct
27 Correct 13 ms 1400 KB Output is correct
28 Correct 26 ms 2808 KB Output is correct
29 Correct 36 ms 3704 KB Output is correct
30 Correct 41 ms 4216 KB Output is correct
31 Correct 43 ms 4472 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1400 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 8 ms 1016 KB Output is correct
8 Correct 8 ms 1016 KB Output is correct
9 Correct 12 ms 1400 KB Output is correct
10 Correct 3 ms 400 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 476 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 400 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 296 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 4 ms 404 KB Output is correct
38 Correct 8 ms 1016 KB Output is correct
39 Correct 4 ms 504 KB Output is correct
40 Correct 4 ms 504 KB Output is correct
41 Correct 5 ms 504 KB Output is correct
42 Correct 8 ms 888 KB Output is correct
43 Correct 5 ms 632 KB Output is correct
44 Correct 8 ms 888 KB Output is correct
45 Correct 11 ms 1144 KB Output is correct
46 Correct 13 ms 1272 KB Output is correct
47 Correct 13 ms 1400 KB Output is correct
48 Correct 3 ms 504 KB Output is correct
49 Correct 9 ms 888 KB Output is correct
50 Correct 9 ms 936 KB Output is correct
51 Correct 11 ms 1016 KB Output is correct
52 Correct 4 ms 504 KB Output is correct
53 Correct 7 ms 760 KB Output is correct
54 Correct 10 ms 1016 KB Output is correct
55 Correct 10 ms 1016 KB Output is correct
56 Correct 3 ms 504 KB Output is correct
57 Correct 6 ms 760 KB Output is correct
58 Correct 9 ms 888 KB Output is correct
59 Correct 9 ms 888 KB Output is correct
60 Correct 10 ms 1016 KB Output is correct
61 Correct 10 ms 1016 KB Output is correct
62 Correct 3 ms 504 KB Output is correct
63 Correct 6 ms 760 KB Output is correct
64 Correct 9 ms 888 KB Output is correct
65 Correct 9 ms 972 KB Output is correct
66 Correct 10 ms 1016 KB Output is correct
67 Correct 10 ms 1016 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 2 ms 376 KB Output is correct
70 Correct 2 ms 376 KB Output is correct
71 Correct 2 ms 256 KB Output is correct
72 Correct 3 ms 504 KB Output is correct
73 Correct 5 ms 632 KB Output is correct
74 Correct 6 ms 760 KB Output is correct
75 Correct 6 ms 760 KB Output is correct
76 Correct 6 ms 760 KB Output is correct
77 Correct 4 ms 504 KB Output is correct
78 Correct 7 ms 760 KB Output is correct
79 Correct 9 ms 888 KB Output is correct
80 Correct 10 ms 1016 KB Output is correct
81 Correct 10 ms 1016 KB Output is correct
82 Correct 3 ms 504 KB Output is correct
83 Correct 8 ms 760 KB Output is correct
84 Correct 2 ms 1016 KB Output is correct
85 Correct 10 ms 1016 KB Output is correct
86 Correct 3 ms 504 KB Output is correct
87 Correct 8 ms 888 KB Output is correct
88 Correct 10 ms 1016 KB Output is correct
89 Correct 8 ms 888 KB Output is correct
90 Correct 18 ms 1912 KB Output is correct
91 Correct 23 ms 2424 KB Output is correct
92 Correct 25 ms 2552 KB Output is correct
93 Correct 8 ms 1016 KB Output is correct
94 Correct 21 ms 2316 KB Output is correct
95 Correct 25 ms 2680 KB Output is correct
96 Correct 13 ms 1400 KB Output is correct
97 Correct 26 ms 2808 KB Output is correct
98 Correct 36 ms 3704 KB Output is correct
99 Correct 41 ms 4216 KB Output is correct
100 Correct 43 ms 4472 KB Output is correct
101 Correct 2 ms 376 KB Output is correct
102 Correct 2 ms 256 KB Output is correct
103 Correct 14 ms 1400 KB Output is correct
104 Correct 2 ms 256 KB Output is correct
105 Correct 5 ms 504 KB Output is correct
106 Correct 5 ms 504 KB Output is correct
107 Correct 4 ms 504 KB Output is correct
108 Correct 3 ms 504 KB Output is correct
109 Correct 8 ms 1016 KB Output is correct
110 Correct 8 ms 1016 KB Output is correct
111 Correct 12 ms 1400 KB Output is correct
112 Correct 3 ms 400 KB Output is correct
113 Correct 2 ms 376 KB Output is correct
114 Correct 25 ms 2680 KB Output is correct
115 Correct 10 ms 1016 KB Output is correct
116 Correct 3 ms 504 KB Output is correct
117 Correct 24 ms 2552 KB Output is correct
118 Correct 13 ms 1528 KB Output is correct
119 Correct 35 ms 3704 KB Output is correct
120 Correct 35 ms 3576 KB Output is correct
121 Correct 35 ms 3704 KB Output is correct
122 Correct 35 ms 3708 KB Output is correct
123 Correct 13 ms 1400 KB Output is correct
124 Correct 27 ms 2680 KB Output is correct
125 Correct 36 ms 3704 KB Output is correct
126 Correct 35 ms 3704 KB Output is correct
127 Correct 42 ms 4216 KB Output is correct
128 Correct 43 ms 4476 KB Output is correct