Submission #417514

# Submission time Handle Problem Language Result Execution time Memory
417514 2021-06-03T20:47:41 Z priority_queue Vision Program (IOI19_vision) C++14
100 / 100
31 ms 2816 KB
#include <bits/stdc++.h>
 
#define forint(i, N) for (int i = 0; i < (N); i++)
 
using namespace std;
 
//vector<int> v = {1, 0, 0, 0, 1, 0};
//vector<int> v = {0, 1, 0, 1, 0, 0};
vector<int> v = {0, 0, 1, 1, 0, 0};

int add_not(int N);
int add_and(vector<int> N);
int add_or(vector<int> N);
int add_xor(vector<int> N);
int cc;
 
/*
int is_k(int& pos, vector<int>& vec, int k) {
	vector<int> vec_test;
	forint(i, vec.size() - k) {
		pos++;
		vec_test.push_back(pos);
		add_and({vec[i], vec[i + k]});
	}
	pos++;
	add_or(vec_test);
	return pos;
}

int is_at_most_k(int& pos, vector<int>& vec, int k) {

	// == 0
	pos++;
	add_xor(vec);

	pos++;
	add_not(pos-1);

	vector<int> vec2 = {pos};

	// >= 1
	forint(i, vec.size() - k) {
		vector<int> tmp;
		for (int j = i; j <= i + k; j++) {
			tmp.push_back(vec[j]);
		}

		pos++; 
		add_xor(tmp);

		pos++;
		add_or(tmp);

		pos++;
		add_and({pos-2, pos-1});
		vec2.push_back(pos);
	}

	pos++;
	add_or(vec2);

	return pos;
}
*/


int is_k(vector<int>& vec, int k) {

	//for(auto i:vec) {
	//	cerr << v[i] << " ";
	//}

	vector<int> vec_test;
	forint(i, vec.size() - k) {
		//int j;
		vec_test.push_back(add_and({vec[i], vec[i + k]}));
		//cerr << v[vec[i]] << "&" << v[vec[i+k]] << "=" << v[j] << "<-\n";
	}
	return add_or(vec_test);
}

int is_at_most_k(vector<int>& vec, int k) {
	//for(auto i:vec) {
	//	cerr << v[i] << " ";
	//}

	// == 0
	//int j;
	vector<int> vec2 = {add_xor(vec)};
	//cerr << v[j] << " -XOR- " << endl;

	// >= 1
	forint(i, vec.size() - k) {
		//cerr << i << " ------- " << endl;
		vector<int> tmp;
		for (int j = i; j <= i + k; j++) {
			tmp.push_back(vec[j]);
		}
		vec2.push_back(add_and({add_not(add_xor(tmp)), add_or(tmp)}));

		//cerr << v[j] << " ++ " << endl;
	}
	return add_or(vec2);
}

void construct_network(int h, int w, int k) {
	
	cc = h * w - 1;

	vector<int> right;
 
	int vsize = h * w - 1;
	for (int i = h - 1; i >= 1; i--) {
		int a = i;
		int b = 0;
		vector<int> tmp;
		while (b < w && a < h) {
			//cerr << a * w + b << " ";
			tmp.push_back(a * w + b);
			a++;
			b++;
		}
		//cerr << endl << " r";
		vsize++;
		right.push_back(vsize);
		add_or(tmp);
	}
	
	for (int i = 0; i < w; i++) {
		int a = 0;
		int b = i;
		vector<int> tmp;
		while (b < w && a < h) {
			//cerr << a * w + b << " ";
			tmp.push_back(a * w + b);
			a++;
			b++;
		}
		//cerr << endl << " r";
		vsize++;
		right.push_back(vsize);
		add_or(tmp);
	}
 
	//cerr << vsize << " right diagonal" << endl;
 
	vector<int> left;
 
	for (int i = 0; i < h - 1; i++) {
		int a = i;
		int b = 0; 
		vector<int> tmp;
		while (b < w && a >= 0) {
			tmp.push_back(a * w + b);
			a--;
			b++;
		}
		vsize++;
		left.push_back(vsize);
		add_or(tmp);
	}
 
	for (int i = 0; i < w; i++) {
		int a = h - 1;
		int b = i;
		vector<int> tmp;
		while (b < w && a >= 0) {
			tmp.push_back(a * w + b);
			a--;
			b++;
		}
		vsize++;
		left.push_back(vsize);
		add_or(tmp);
	}

	/*
	add_and({is_k(vsize, right, k), is_at_most_k(vsize, left, k)});
	int a = ++vsize;
	
	add_and({is_k(vsize, left, k), is_at_most_k(vsize, right, k)});
	int b = ++vsize;
	*/

	//int a, b;

	add_or({
		add_and({is_k(right, k), is_at_most_k(left, k)}), 
		add_and({is_k(left, k), is_at_most_k(right, k)})
	});

	//cerr << v[a] << " -- " << v[b] << endl;
}

Compilation message

vision.cpp: In function 'int is_k(std::vector<int>&, int)':
vision.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define forint(i, N) for (int i = 0; i < (N); i++)
      |                                        ^
vision.cpp:74:2: note: in expansion of macro 'forint'
   74 |  forint(i, vec.size() - k) {
      |  ^~~~~~
vision.cpp: In function 'int is_at_most_k(std::vector<int>&, int)':
vision.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define forint(i, N) for (int i = 0; i < (N); i++)
      |                                        ^
vision.cpp:93:2: note: in expansion of macro 'forint'
   93 |  forint(i, vec.size() - k) {
      |  ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 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 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 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 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 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 204 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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 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 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 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 204 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 1 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 2 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 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 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 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 204 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 1 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 2 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 292 KB Output is correct
38 Correct 7 ms 880 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 460 KB Output is correct
42 Correct 3 ms 416 KB Output is correct
43 Correct 5 ms 716 KB Output is correct
44 Correct 7 ms 800 KB Output is correct
45 Correct 8 ms 884 KB Output is correct
46 Correct 7 ms 764 KB Output is correct
47 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 6 ms 596 KB Output is correct
3 Correct 6 ms 716 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 5 ms 588 KB Output is correct
7 Correct 5 ms 548 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 528 KB Output is correct
10 Correct 5 ms 588 KB Output is correct
11 Correct 6 ms 716 KB Output is correct
12 Correct 6 ms 716 KB Output is correct
13 Correct 4 ms 588 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 5 ms 588 KB Output is correct
17 Correct 6 ms 672 KB Output is correct
18 Correct 6 ms 716 KB Output is correct
19 Correct 4 ms 588 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 292 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 3 ms 460 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 7 ms 716 KB Output is correct
10 Correct 8 ms 716 KB Output is correct
11 Correct 5 ms 588 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 460 KB Output is correct
14 Correct 5 ms 588 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 5 ms 716 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 8 ms 972 KB Output is correct
21 Correct 24 ms 1572 KB Output is correct
22 Correct 15 ms 1504 KB Output is correct
23 Correct 6 ms 716 KB Output is correct
24 Correct 7 ms 972 KB Output is correct
25 Correct 16 ms 1704 KB Output is correct
26 Correct 6 ms 716 KB Output is correct
27 Correct 13 ms 1400 KB Output is correct
28 Correct 26 ms 2444 KB Output is correct
29 Correct 29 ms 2756 KB Output is correct
30 Correct 24 ms 2288 KB Output is correct
31 Correct 14 ms 1100 KB Output is correct
32 Correct 1 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 1440 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 8 ms 972 KB Output is correct
8 Correct 10 ms 972 KB Output is correct
9 Correct 13 ms 1416 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 288 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 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 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 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 204 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 1 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 2 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 292 KB Output is correct
38 Correct 7 ms 880 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 460 KB Output is correct
42 Correct 3 ms 416 KB Output is correct
43 Correct 5 ms 716 KB Output is correct
44 Correct 7 ms 800 KB Output is correct
45 Correct 8 ms 884 KB Output is correct
46 Correct 7 ms 764 KB Output is correct
47 Correct 3 ms 460 KB Output is correct
48 Correct 3 ms 460 KB Output is correct
49 Correct 6 ms 596 KB Output is correct
50 Correct 6 ms 716 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 2 ms 544 KB Output is correct
53 Correct 5 ms 588 KB Output is correct
54 Correct 5 ms 548 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 2 ms 528 KB Output is correct
57 Correct 5 ms 588 KB Output is correct
58 Correct 6 ms 716 KB Output is correct
59 Correct 6 ms 716 KB Output is correct
60 Correct 4 ms 588 KB Output is correct
61 Correct 1 ms 292 KB Output is correct
62 Correct 2 ms 460 KB Output is correct
63 Correct 5 ms 588 KB Output is correct
64 Correct 6 ms 672 KB Output is correct
65 Correct 6 ms 716 KB Output is correct
66 Correct 4 ms 588 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 292 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 292 KB Output is correct
72 Correct 2 ms 460 KB Output is correct
73 Correct 3 ms 460 KB Output is correct
74 Correct 4 ms 460 KB Output is correct
75 Correct 3 ms 460 KB Output is correct
76 Correct 2 ms 332 KB Output is correct
77 Correct 3 ms 600 KB Output is correct
78 Correct 7 ms 716 KB Output is correct
79 Correct 8 ms 716 KB Output is correct
80 Correct 5 ms 588 KB Output is correct
81 Correct 2 ms 332 KB Output is correct
82 Correct 2 ms 460 KB Output is correct
83 Correct 5 ms 588 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 5 ms 716 KB Output is correct
88 Correct 1 ms 332 KB Output is correct
89 Correct 8 ms 972 KB Output is correct
90 Correct 24 ms 1572 KB Output is correct
91 Correct 15 ms 1504 KB Output is correct
92 Correct 6 ms 716 KB Output is correct
93 Correct 7 ms 972 KB Output is correct
94 Correct 16 ms 1704 KB Output is correct
95 Correct 6 ms 716 KB Output is correct
96 Correct 13 ms 1400 KB Output is correct
97 Correct 26 ms 2444 KB Output is correct
98 Correct 29 ms 2756 KB Output is correct
99 Correct 24 ms 2288 KB Output is correct
100 Correct 14 ms 1100 KB Output is correct
101 Correct 1 ms 204 KB Output is correct
102 Correct 1 ms 204 KB Output is correct
103 Correct 13 ms 1440 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 2 ms 476 KB Output is correct
106 Correct 3 ms 588 KB Output is correct
107 Correct 2 ms 460 KB Output is correct
108 Correct 2 ms 460 KB Output is correct
109 Correct 8 ms 972 KB Output is correct
110 Correct 10 ms 972 KB Output is correct
111 Correct 13 ms 1416 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 25 ms 2432 KB Output is correct
115 Correct 1 ms 332 KB Output is correct
116 Correct 2 ms 460 KB Output is correct
117 Correct 12 ms 1128 KB Output is correct
118 Correct 13 ms 1356 KB Output is correct
119 Correct 29 ms 2768 KB Output is correct
120 Correct 31 ms 2776 KB Output is correct
121 Correct 31 ms 2764 KB Output is correct
122 Correct 29 ms 2816 KB Output is correct
123 Correct 13 ms 1436 KB Output is correct
124 Correct 25 ms 2460 KB Output is correct
125 Correct 29 ms 2756 KB Output is correct
126 Correct 29 ms 2804 KB Output is correct
127 Correct 24 ms 2388 KB Output is correct
128 Correct 10 ms 1168 KB Output is correct