Submission #825982

# Submission time Handle Problem Language Result Execution time Memory
825982 2023-08-15T09:41:59 Z caganyanmaz Vision Program (IOI19_vision) C++17
100 / 100
24 ms 2920 KB
#include "vision.h"
#define pb push_back
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif

int h, w, k;

static inline bool in_bounds(int i, int j)
{
	return i >= 0 && j >= 0 && i < h && j < w;
}

static inline int serialize(int i, int j)
{
	return i * w + j;
}

array<int, 2> calculate(int left_bound, int right_bound)
{
	vector<int> vals;
	for (int i = left_bound; i+k <= right_bound; i++)
	{
		if (i+k <= right_bound)
		{
			vector<int> v;
			v.pb(i);
			v.pb(i+k);
			vals.pb(add_and(v));
		}
	}
	debug(vals);
	int ek1;
	{
		vector<int> v;
		for (int i : vals)
			v.pb(i);
		ek1 = add_or(v);
	}
	debug("b");
	vector<int> _nots;
	for (int i = left_bound; i+k < right_bound; i++)
	{
		vector<int> v;
		for (int j = i+k+1; j <= right_bound; j++)
			v.pb(j);
		if (v.empty())
			continue;
		int _new = add_or(v);
		v.clear();
		v.pb(_new);
		v.pb(i);
		_nots.pb(add_and(v));// If both open its greater than
	}
	debug("c");
	int gk1;
	if (_nots.size())
	{
		gk1 = add_or(_nots);
	}
	debug("d");
	return array<int, 2> ({ek1, gk1});
}

void construct_network(int H, int W, int K)
{
	h = H, w = W, k = K;
	int left_bound = -1, right_bound = -1;
	for (int l = 0; l <= W+H; l++)
	{
		vector<int> v;
		for (int i = 0; i < h; i++)
		{
			int j = l-i;
			if (in_bounds(i, j))
				v.pb(serialize(i, j));
		}
		if (v.size() > 0)
			right_bound = add_or(v);
		if (left_bound == -1 && right_bound != -1)
			left_bound = right_bound;
	}
	auto [ek1, gk1] =calculate(left_bound, right_bound);
	left_bound = -1, right_bound = -1;
	for (int l = 0; l <= W+H; l++)
	{
		vector<int> v;
		for (int i = 0; i < h; i++)
		{
			int j = i+w-l;
			if (in_bounds(i, j))
				v.pb(serialize(i, j));
		}
		if (v.size() > 0)
			right_bound = add_or(v);
		if (left_bound == -1 && right_bound != -1)
			left_bound = right_bound;
	}
	auto [ek2, gk2] = calculate(left_bound, right_bound);
	if (k < w + h - 2)
	{
		vector<int> v;
		v.pb(gk1);
		v.pb(gk2);
		int a = add_or(v);
		int not_greater = add_not(a);
		v.clear();
		v.pb(ek1);
		v.pb(ek2);
		int equal = add_or(v);
		v.clear();
		v.pb(not_greater);
		v.pb(equal);
		add_and(v);
	}
	else
	{
		vector<int> v;
		v.pb(ek1);
		v.pb(ek2);
		add_or(v);
	}

}

Compilation message

vision.cpp: In function 'std::array<int, 2> calculate(int, int)':
vision.cpp:67:34: warning: 'gk1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |  return array<int, 2> ({ek1, gk1});
      |                                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 4 ms 692 KB Output is correct
39 Correct 1 ms 324 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 5 ms 596 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 6 ms 968 KB Output is correct
44 Correct 4 ms 724 KB Output is correct
45 Correct 4 ms 596 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 724 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 5 ms 724 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 4 ms 516 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 4 ms 724 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 5 ms 700 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 4 ms 724 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 14 ms 1684 KB Output is correct
21 Correct 8 ms 1104 KB Output is correct
22 Correct 8 ms 844 KB Output is correct
23 Correct 4 ms 632 KB Output is correct
24 Correct 16 ms 1752 KB Output is correct
25 Correct 8 ms 984 KB Output is correct
26 Correct 4 ms 596 KB Output is correct
27 Correct 23 ms 2920 KB Output is correct
28 Correct 18 ms 2076 KB Output is correct
29 Correct 15 ms 1496 KB Output is correct
30 Correct 10 ms 1172 KB Output is correct
31 Correct 7 ms 1040 KB Output is correct
32 Correct 1 ms 224 KB Output is correct
33 Correct 0 ms 224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2808 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 6 ms 724 KB Output is correct
5 Correct 4 ms 732 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 12 ms 1648 KB Output is correct
8 Correct 12 ms 1756 KB Output is correct
9 Correct 22 ms 2800 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 4 ms 692 KB Output is correct
39 Correct 1 ms 324 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 5 ms 596 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 6 ms 968 KB Output is correct
44 Correct 4 ms 724 KB Output is correct
45 Correct 4 ms 596 KB Output is correct
46 Correct 3 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 4 ms 724 KB Output is correct
49 Correct 2 ms 340 KB Output is correct
50 Correct 2 ms 340 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 5 ms 724 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 4 ms 724 KB Output is correct
57 Correct 4 ms 516 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 2 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 4 ms 724 KB Output is correct
63 Correct 3 ms 468 KB Output is correct
64 Correct 2 ms 340 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 3 ms 596 KB Output is correct
73 Correct 2 ms 468 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
75 Correct 2 ms 340 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 5 ms 700 KB Output is correct
78 Correct 3 ms 596 KB Output is correct
79 Correct 3 ms 468 KB Output is correct
80 Correct 2 ms 468 KB Output is correct
81 Correct 1 ms 340 KB Output is correct
82 Correct 4 ms 724 KB Output is correct
83 Correct 2 ms 468 KB Output is correct
84 Correct 1 ms 340 KB Output is correct
85 Correct 0 ms 212 KB Output is correct
86 Correct 4 ms 724 KB Output is correct
87 Correct 2 ms 340 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 14 ms 1684 KB Output is correct
90 Correct 8 ms 1104 KB Output is correct
91 Correct 8 ms 844 KB Output is correct
92 Correct 4 ms 632 KB Output is correct
93 Correct 16 ms 1752 KB Output is correct
94 Correct 8 ms 984 KB Output is correct
95 Correct 4 ms 596 KB Output is correct
96 Correct 23 ms 2920 KB Output is correct
97 Correct 18 ms 2076 KB Output is correct
98 Correct 15 ms 1496 KB Output is correct
99 Correct 10 ms 1172 KB Output is correct
100 Correct 7 ms 1040 KB Output is correct
101 Correct 1 ms 224 KB Output is correct
102 Correct 0 ms 224 KB Output is correct
103 Correct 24 ms 2808 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 3 ms 596 KB Output is correct
106 Correct 6 ms 724 KB Output is correct
107 Correct 4 ms 732 KB Output is correct
108 Correct 4 ms 724 KB Output is correct
109 Correct 12 ms 1648 KB Output is correct
110 Correct 12 ms 1756 KB Output is correct
111 Correct 22 ms 2800 KB Output is correct
112 Correct 1 ms 312 KB Output is correct
113 Correct 0 ms 212 KB Output is correct
114 Correct 16 ms 2112 KB Output is correct
115 Correct 1 ms 212 KB Output is correct
116 Correct 5 ms 700 KB Output is correct
117 Correct 5 ms 724 KB Output is correct
118 Correct 10 ms 1464 KB Output is correct
119 Correct 12 ms 1584 KB Output is correct
120 Correct 15 ms 1560 KB Output is correct
121 Correct 11 ms 1548 KB Output is correct
122 Correct 11 ms 1580 KB Output is correct
123 Correct 21 ms 2900 KB Output is correct
124 Correct 16 ms 2180 KB Output is correct
125 Correct 11 ms 1508 KB Output is correct
126 Correct 12 ms 1592 KB Output is correct
127 Correct 9 ms 1204 KB Output is correct
128 Correct 8 ms 1120 KB Output is correct