Submission #823507

# Submission time Handle Problem Language Result Execution time Memory
823507 2023-08-12T15:42:24 Z Ronin13 Vision Program (IOI19_vision) C++17
100 / 100
25 ms 3736 KB
#include "vision.h"
#include <bits/stdc++.h>
#define ll long long 
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned long long
using namespace std;

vector <int> a, b;

vector <vector <int> > x(401);
vector <vector <int> >y(401);

void construct_network(int H, int W, int K) {
	int n = H, m = W, k = K;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			x[i + j].pb(i * m + j);
			y[i - j + m].pb(i * m + j);
		}
	}
	vector <int> all;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			all.pb(i * m + j);
		}
	}
	add_or(all);
	int cur = n * m + 1;
	for(int j = 0; j < n + m - 1; j++){
		a.pb(cur++);
		add_or(x[j]);
	}
	for(int j = -m + 1; j <= n - 1; j++){
		b.pb(cur++);
		add_or(y[j + m]);
	}
	
	vector <int> vv;

	for(int i = 0; i < a.size(); i++){
		
		if(i + k >= a.size()) vv.pb(cur++), add_not(n * m);
		else add_and({a[i], a[i + k]}),  vv.pb(cur++);
	}
	
	int A = cur++;
	add_or(vv);
	vv.clear();
	for(int i = 0; i < b.size(); i++){
		if(i + k >= b.size()) vv.pb(cur++), add_not(n * m);
		else add_and({b[i], b[i + k]}), vv.pb(cur++);
	}
	
	int B = cur++;
	add_or(vv);
	vv.clear();
	for(int i = 0; i < a.size(); i++){
		if(i + k + 1 >= a.size()) add_not(n * m), vv.pb(cur++);
		else{
			vector <int> x;
			for(int j = i + k + 1; j < a.size(); j++){
				x.pb(a[j]);
			}
			cur++, add_or(x);
			add_and({a[i], cur - 1});
			vv.pb(cur++);
		}
	}
	int C = cur++;
	add_or(vv);
	add_not(C);
	C = cur++;
	vv.clear();
	for(int i = 0; i < b.size(); i++){
		if(i + k + 1 >= b.size()) add_not(n * m), vv.pb(cur++);
		else{
			vector <int> x;
			for(int j = i + k + 1; j < b.size(); j++){
				x.pb(b[j]);
			}
			cur++, add_or(x);
			add_and({b[i], cur - 1});
			vv.pb(cur++);
		}
	}
	int D = cur++;
	add_or(vv);
	add_not(D);
	D = cur++;
	add_and({A, D});
	cur++;
	add_and({B, C});
	cur++;
	add_or({cur - 1, cur - 2});
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(int i = 0; i < a.size(); i++){
      |                 ~~^~~~~~~~~~
vision.cpp:47:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   if(i + k >= a.size()) vv.pb(cur++), add_not(n * m);
      |      ~~~~~~^~~~~~~~~~~
vision.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int i = 0; i < b.size(); i++){
      |                 ~~^~~~~~~~~~
vision.cpp:55:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   if(i + k >= b.size()) vv.pb(cur++), add_not(n * m);
      |      ~~~~~~^~~~~~~~~~~
vision.cpp:62:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |  for(int i = 0; i < a.size(); i++){
      |                 ~~^~~~~~~~~~
vision.cpp:63:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   if(i + k + 1 >= a.size()) add_not(n * m), vv.pb(cur++);
      |      ~~~~~~~~~~^~~~~~~~~~~
vision.cpp:66:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |    for(int j = i + k + 1; j < a.size(); j++){
      |                           ~~^~~~~~~~~~
vision.cpp:79:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |  for(int i = 0; i < b.size(); i++){
      |                 ~~^~~~~~~~~~
vision.cpp:80:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |   if(i + k + 1 >= b.size()) add_not(n * m), vv.pb(cur++);
      |      ~~~~~~~~~~^~~~~~~~~~~
vision.cpp:83:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |    for(int j = i + k + 1; j < b.size(); j++){
      |                           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 220 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 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 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 220 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 220 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 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 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 316 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 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 220 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 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 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 316 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 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 5 ms 980 KB Output is correct
39 Correct 1 ms 372 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 4 ms 724 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 7 ms 1212 KB Output is correct
44 Correct 7 ms 1088 KB Output is correct
45 Correct 6 ms 832 KB Output is correct
46 Correct 4 ms 852 KB Output is correct
47 Correct 4 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 724 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 704 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 444 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 3 ms 444 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 2 ms 444 KB Output is correct
14 Correct 1 ms 472 KB Output is correct
15 Correct 4 ms 724 KB Output is correct
16 Correct 3 ms 596 KB Output is correct
17 Correct 2 ms 448 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 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 596 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 5 ms 852 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 3 ms 700 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 4 ms 724 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 14 ms 2236 KB Output is correct
21 Correct 12 ms 1748 KB Output is correct
22 Correct 7 ms 1364 KB Output is correct
23 Correct 9 ms 1320 KB Output is correct
24 Correct 14 ms 2260 KB Output is correct
25 Correct 8 ms 1600 KB Output is correct
26 Correct 6 ms 1236 KB Output is correct
27 Correct 25 ms 3704 KB Output is correct
28 Correct 19 ms 3100 KB Output is correct
29 Correct 15 ms 2584 KB Output is correct
30 Correct 15 ms 2200 KB Output is correct
31 Correct 11 ms 2172 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 3736 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 3 ms 572 KB Output is correct
4 Correct 5 ms 980 KB Output is correct
5 Correct 4 ms 700 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 15 ms 2264 KB Output is correct
8 Correct 14 ms 2236 KB Output is correct
9 Correct 25 ms 3716 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 220 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 324 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 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 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 316 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 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 5 ms 980 KB Output is correct
39 Correct 1 ms 372 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 4 ms 724 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 7 ms 1212 KB Output is correct
44 Correct 7 ms 1088 KB Output is correct
45 Correct 6 ms 832 KB Output is correct
46 Correct 4 ms 852 KB Output is correct
47 Correct 4 ms 852 KB Output is correct
48 Correct 6 ms 724 KB Output is correct
49 Correct 2 ms 468 KB Output is correct
50 Correct 2 ms 444 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 4 ms 704 KB Output is correct
53 Correct 2 ms 596 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 1 ms 444 KB Output is correct
56 Correct 4 ms 724 KB Output is correct
57 Correct 3 ms 576 KB Output is correct
58 Correct 3 ms 444 KB Output is correct
59 Correct 3 ms 468 KB Output is correct
60 Correct 2 ms 444 KB Output is correct
61 Correct 1 ms 472 KB Output is correct
62 Correct 4 ms 724 KB Output is correct
63 Correct 3 ms 596 KB Output is correct
64 Correct 2 ms 448 KB Output is correct
65 Correct 2 ms 468 KB Output is correct
66 Correct 1 ms 468 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 1 ms 320 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 596 KB Output is correct
74 Correct 2 ms 468 KB Output is correct
75 Correct 2 ms 468 KB Output is correct
76 Correct 2 ms 468 KB Output is correct
77 Correct 5 ms 852 KB Output is correct
78 Correct 4 ms 724 KB Output is correct
79 Correct 3 ms 700 KB Output is correct
80 Correct 2 ms 596 KB Output is correct
81 Correct 2 ms 596 KB Output is correct
82 Correct 4 ms 724 KB Output is correct
83 Correct 3 ms 596 KB Output is correct
84 Correct 1 ms 468 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 4 ms 724 KB Output is correct
87 Correct 2 ms 468 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 14 ms 2236 KB Output is correct
90 Correct 12 ms 1748 KB Output is correct
91 Correct 7 ms 1364 KB Output is correct
92 Correct 9 ms 1320 KB Output is correct
93 Correct 14 ms 2260 KB Output is correct
94 Correct 8 ms 1600 KB Output is correct
95 Correct 6 ms 1236 KB Output is correct
96 Correct 25 ms 3704 KB Output is correct
97 Correct 19 ms 3100 KB Output is correct
98 Correct 15 ms 2584 KB Output is correct
99 Correct 15 ms 2200 KB Output is correct
100 Correct 11 ms 2172 KB Output is correct
101 Correct 1 ms 212 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 24 ms 3736 KB Output is correct
104 Correct 0 ms 212 KB Output is correct
105 Correct 3 ms 572 KB Output is correct
106 Correct 5 ms 980 KB Output is correct
107 Correct 4 ms 700 KB Output is correct
108 Correct 4 ms 724 KB Output is correct
109 Correct 15 ms 2264 KB Output is correct
110 Correct 14 ms 2236 KB Output is correct
111 Correct 25 ms 3716 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 24 ms 3000 KB Output is correct
115 Correct 2 ms 444 KB Output is correct
116 Correct 4 ms 724 KB Output is correct
117 Correct 7 ms 1348 KB Output is correct
118 Correct 12 ms 2036 KB Output is correct
119 Correct 16 ms 2464 KB Output is correct
120 Correct 16 ms 2516 KB Output is correct
121 Correct 16 ms 2516 KB Output is correct
122 Correct 16 ms 2532 KB Output is correct
123 Correct 25 ms 3720 KB Output is correct
124 Correct 20 ms 2988 KB Output is correct
125 Correct 20 ms 2584 KB Output is correct
126 Correct 17 ms 2448 KB Output is correct
127 Correct 12 ms 2260 KB Output is correct
128 Correct 12 ms 2176 KB Output is correct