Submission #388526

# Submission time Handle Problem Language Result Execution time Memory
388526 2021-04-11T21:54:54 Z JimmyZJX Vision Program (IOI19_vision) C++14
100 / 100
38 ms 3352 KB
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cassert>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string>

using namespace std;

typedef long long LL;
typedef vector<int> Vi;
typedef vector<bool> Vb;
typedef vector<vector<int>> Vii;

#define forR(i, n) for (int i = 0; i < (n); i++)

int add_not(int N);
void Get_le_k(Vi& rs, Vi& d1r, int K, int& dd1_le_k);
int add_and(Vi Ns);
int add_or(Vi Ns);
int add_xor(Vi Ns);

int Get_le_k(const Vi& dr, int K)
{
	Vi rs;
	for (int i = 0; i < dr.size() - K; i++) {
		Vi range; // [i, i+K]
		for (int j = 0; j <= K; j++) {
			range.push_back(dr[i + j]);
		}
		int or_range = add_or(range);
		int xor_range = add_xor(range);
		rs.push_back(add_and(Vi{ or_range, add_not(xor_range) }));
	}
	int dd_ge1_leK = add_or(rs);

	int dd_eq0 = add_not(add_or(dr));
	return add_or(Vi{ dd_eq0, dd_ge1_leK });
}

void construct_network(int H, int W, int K) {

	// d1[i] x+y == i    d2[i] x+(W-1-y) == i
	Vii d1(H + W - 1), d2(H + W - 1);

	forR(x, H) forR(y, W) {
		int index = x * W + y;

		int i1 = x + y, i2 = x + (W - 1 - y);
		d1[i1].push_back(index); d2[i2].push_back(index);
	}

	Vi d1r, d2r;

	for (auto& d1_line : d1) {
		d1r.push_back(add_xor(d1_line));
	}
	for (auto& d2_line : d2) {
		d2r.push_back(add_xor(d2_line));
	}

	int dd1_eq_k, dd1_le_k, dd2_eq_k, dd2_le_k;
	// d1
	{
		Vi rs;
		for (int i = 0; i < d1r.size() - K; i++) {
			rs.push_back(add_and(Vi{ d1r[i], d1r[i + K] }));
		}
		dd1_eq_k = add_or(rs);

		dd1_le_k = Get_le_k(d1r, K);
	}

	// d2
	{
		Vi rs;
		for (int i = 0; i < d2r.size() - K; i++) {
			rs.push_back(add_and(Vi{ d2r[i], d2r[i + K] }));
		}
		dd2_eq_k = add_or(rs);

		dd2_le_k = Get_le_k(d2r, K);
	}

	int dd1_k = add_and(Vi{ dd1_eq_k, dd2_le_k });
	int dd2_k = add_and(Vi{ dd2_eq_k, dd1_le_k });

	add_or(Vi{ dd1_k, dd2_k });

	return;
}


#ifdef TEST_LOCAL
int add_not(int N) { return -1; }
int add_and(Vi Ns) { return -1; }
int add_or(Vi Ns) { return -1; }
int add_xor(Vi Ns) { return -1; }

int main() {
	construct_network(200, 200, 1);

	return 0;
}
#endif

Compilation message

vision.cpp: In function 'int Get_le_k(const Vi&, int)':
vision.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 0; i < dr.size() - K; i++) {
      |                  ~~^~~~~~~~~~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:73:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |   for (int i = 0; i < d1r.size() - K; i++) {
      |                   ~~^~~~~~~~~~~~~~~~
vision.cpp:84:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |   for (int i = 0; i < d2r.size() - K; i++) {
      |                   ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 232 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 232 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 232 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 7 ms 972 KB Output is correct
39 Correct 2 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 3 ms 588 KB Output is correct
42 Correct 2 ms 460 KB Output is correct
43 Correct 4 ms 844 KB Output is correct
44 Correct 7 ms 972 KB Output is correct
45 Correct 8 ms 972 KB Output is correct
46 Correct 7 ms 844 KB Output is correct
47 Correct 3 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 5 ms 716 KB Output is correct
3 Correct 5 ms 716 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 556 KB Output is correct
6 Correct 5 ms 716 KB Output is correct
7 Correct 5 ms 588 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 5 ms 588 KB Output is correct
11 Correct 5 ms 716 KB Output is correct
12 Correct 5 ms 716 KB Output is correct
13 Correct 4 ms 616 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 3 ms 460 KB Output is correct
16 Correct 5 ms 588 KB Output is correct
17 Correct 5 ms 716 KB Output is correct
18 Correct 5 ms 716 KB Output is correct
19 Correct 4 ms 588 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 5 ms 560 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 3 ms 716 KB Output is correct
9 Correct 6 ms 800 KB Output is correct
10 Correct 6 ms 844 KB Output is correct
11 Correct 5 ms 716 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 2 ms 460 KB Output is correct
14 Correct 5 ms 592 KB Output is correct
15 Correct 5 ms 588 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 7 ms 716 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 7 ms 1128 KB Output is correct
21 Correct 17 ms 1768 KB Output is correct
22 Correct 14 ms 1780 KB Output is correct
23 Correct 6 ms 844 KB Output is correct
24 Correct 7 ms 1100 KB Output is correct
25 Correct 16 ms 1996 KB Output is correct
26 Correct 6 ms 912 KB Output is correct
27 Correct 13 ms 1864 KB Output is correct
28 Correct 25 ms 3012 KB Output is correct
29 Correct 29 ms 3352 KB Output is correct
30 Correct 24 ms 2892 KB Output is correct
31 Correct 10 ms 1612 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1932 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 7 ms 1192 KB Output is correct
8 Correct 8 ms 1228 KB Output is correct
9 Correct 16 ms 1972 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 232 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 7 ms 972 KB Output is correct
39 Correct 2 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 3 ms 588 KB Output is correct
42 Correct 2 ms 460 KB Output is correct
43 Correct 4 ms 844 KB Output is correct
44 Correct 7 ms 972 KB Output is correct
45 Correct 8 ms 972 KB Output is correct
46 Correct 7 ms 844 KB Output is correct
47 Correct 3 ms 588 KB Output is correct
48 Correct 2 ms 460 KB Output is correct
49 Correct 5 ms 716 KB Output is correct
50 Correct 5 ms 716 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 2 ms 556 KB Output is correct
53 Correct 5 ms 716 KB Output is correct
54 Correct 5 ms 588 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 2 ms 460 KB Output is correct
57 Correct 5 ms 588 KB Output is correct
58 Correct 5 ms 716 KB Output is correct
59 Correct 5 ms 716 KB Output is correct
60 Correct 4 ms 616 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 3 ms 460 KB Output is correct
63 Correct 5 ms 588 KB Output is correct
64 Correct 5 ms 716 KB Output is correct
65 Correct 5 ms 716 KB Output is correct
66 Correct 4 ms 588 KB Output is correct
67 Correct 1 ms 336 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 0 ms 204 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 3 ms 460 KB Output is correct
73 Correct 5 ms 560 KB Output is correct
74 Correct 3 ms 588 KB Output is correct
75 Correct 3 ms 460 KB Output is correct
76 Correct 1 ms 332 KB Output is correct
77 Correct 3 ms 716 KB Output is correct
78 Correct 6 ms 800 KB Output is correct
79 Correct 6 ms 844 KB Output is correct
80 Correct 5 ms 716 KB Output is correct
81 Correct 2 ms 460 KB Output is correct
82 Correct 2 ms 460 KB Output is correct
83 Correct 5 ms 592 KB Output is correct
84 Correct 5 ms 588 KB Output is correct
85 Correct 1 ms 332 KB Output is correct
86 Correct 2 ms 460 KB Output is correct
87 Correct 7 ms 716 KB Output is correct
88 Correct 1 ms 332 KB Output is correct
89 Correct 7 ms 1128 KB Output is correct
90 Correct 17 ms 1768 KB Output is correct
91 Correct 14 ms 1780 KB Output is correct
92 Correct 6 ms 844 KB Output is correct
93 Correct 7 ms 1100 KB Output is correct
94 Correct 16 ms 1996 KB Output is correct
95 Correct 6 ms 912 KB Output is correct
96 Correct 13 ms 1864 KB Output is correct
97 Correct 25 ms 3012 KB Output is correct
98 Correct 29 ms 3352 KB Output is correct
99 Correct 24 ms 2892 KB Output is correct
100 Correct 10 ms 1612 KB Output is correct
101 Correct 0 ms 204 KB Output is correct
102 Correct 1 ms 204 KB Output is correct
103 Correct 13 ms 1932 KB Output is correct
104 Correct 0 ms 204 KB Output is correct
105 Correct 2 ms 460 KB Output is correct
106 Correct 3 ms 716 KB Output is correct
107 Correct 2 ms 460 KB Output is correct
108 Correct 3 ms 460 KB Output is correct
109 Correct 7 ms 1192 KB Output is correct
110 Correct 8 ms 1228 KB Output is correct
111 Correct 16 ms 1972 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 208 KB Output is correct
114 Correct 25 ms 2988 KB Output is correct
115 Correct 1 ms 332 KB Output is correct
116 Correct 2 ms 460 KB Output is correct
117 Correct 11 ms 1452 KB Output is correct
118 Correct 13 ms 1652 KB Output is correct
119 Correct 28 ms 3304 KB Output is correct
120 Correct 38 ms 3260 KB Output is correct
121 Correct 29 ms 3300 KB Output is correct
122 Correct 28 ms 3288 KB Output is correct
123 Correct 13 ms 1864 KB Output is correct
124 Correct 25 ms 3020 KB Output is correct
125 Correct 29 ms 3264 KB Output is correct
126 Correct 28 ms 3276 KB Output is correct
127 Correct 24 ms 2872 KB Output is correct
128 Correct 10 ms 1612 KB Output is correct