Submission #869455

# Submission time Handle Problem Language Result Execution time Memory
869455 2023-11-04T11:38:29 Z n1k Vision Program (IOI19_vision) C++17
100 / 100
27 ms 3520 KB
#include "vision.h"
#include <bits/stdc++.h>

using namespace std;

void construct_network(int H, int W, int K) {
	map<int, vector<int>> mpx, mpy;
	for(int r = 0; r < H; r++){
		for(int c = 0; c < W; c++){
			mpx[r + c].push_back(r * W + c);
			mpy[c - r].push_back(r * W + c);
		}
	}
	vector<int> vx, vy, any1, any2, any1smaller, any2smaller;
	for(auto [k, v] : mpx){
		vx.push_back(add_or(v));
	}
	for(auto [k, v] : mpy){
		vy.push_back(add_or(v));
	}
	// determin if we have dist K in one of both
	// (any(dist1 == K) or any(dist2 == K) and dist1 <= K and dist2 <= K)
	// case where two fall on the same diagonal !!!!!!!!!!
	for(int i = 0; i < vx.size(); i++){
		if(i < vx.size() - K)
			any1.push_back(add_and({vx[i], vx[i + K]}));
		//any1smaller.push_back(add_and({vx[i], add_not(add_xor(vector<int>(vx.begin() + i, vx.begin() + min(vx.size(), (size_t) i + K + 1))))}));
		if(i + 1< vx.size())
			any1smaller.push_back(add_and({vx[i], add_or(vector<int>(vx.begin() + i + 1, vx.begin() + min(vx.size(), (size_t) i + K + 1)))}));
	}
	any1smaller.push_back(add_xor(vx));
	for(int i = 0; i < vy.size(); i++){
		if(i < vy.size() - K)
			any2.push_back(add_and({vy[i], vy[i + K]}));
		//any2smaller.push_back(add_and({vy[i], add_not(add_xor(vector<int>(vy.begin() + i, vy.begin() + min(vy.size(), (size_t) i + K + 1))))}));
		if(i + 1 < vy.size())
			any2smaller.push_back(add_and({vy[i], add_or(vector<int>(vy.begin() + i + 1, vy.begin() + min(vy.size(), (size_t) i + K + 1)))}));

	}
	any2smaller.push_back(add_xor(vy));
	// and(x, y)
	add_and({add_or({add_or(any1), add_or(any2)}), add_or(any1smaller), add_or(any2smaller)});
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i = 0; i < vx.size(); i++){
      |                 ~~^~~~~~~~~~~
vision.cpp:25:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if(i < vx.size() - K)
      |      ~~^~~~~~~~~~~~~~~
vision.cpp:28:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if(i + 1< vx.size())
      |      ~~~~~^~~~~~~~~~~
vision.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = 0; i < vy.size(); i++){
      |                 ~~^~~~~~~~~~~
vision.cpp:33:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   if(i < vy.size() - K)
      |      ~~^~~~~~~~~~~~~~~
vision.cpp:36:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   if(i + 1 < vy.size())
      |      ~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 436 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 424 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 436 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 424 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 436 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 1 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 436 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 424 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 436 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 1 ms 544 KB Output is correct
38 Correct 5 ms 860 KB Output is correct
39 Correct 1 ms 436 KB Output is correct
40 Correct 2 ms 344 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 4 ms 856 KB Output is correct
43 Correct 3 ms 860 KB Output is correct
44 Correct 4 ms 984 KB Output is correct
45 Correct 6 ms 1116 KB Output is correct
46 Correct 6 ms 1004 KB Output is correct
47 Correct 6 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 3 ms 616 KB Output is correct
3 Correct 3 ms 692 KB Output is correct
4 Correct 4 ms 692 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 4 ms 860 KB Output is correct
9 Correct 2 ms 616 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 732 KB Output is correct
14 Correct 5 ms 1116 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 4 ms 688 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 860 KB Output is correct
20 Correct 4 ms 860 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 4 ms 860 KB Output is correct
11 Correct 5 ms 860 KB Output is correct
12 Correct 4 ms 860 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 860 KB Output is correct
16 Correct 4 ms 900 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 4 ms 808 KB Output is correct
20 Correct 6 ms 1116 KB Output is correct
21 Correct 10 ms 1716 KB Output is correct
22 Correct 12 ms 1888 KB Output is correct
23 Correct 13 ms 2076 KB Output is correct
24 Correct 6 ms 1120 KB Output is correct
25 Correct 11 ms 1888 KB Output is correct
26 Correct 15 ms 1888 KB Output is correct
27 Correct 12 ms 1888 KB Output is correct
28 Correct 16 ms 2656 KB Output is correct
29 Correct 22 ms 3164 KB Output is correct
30 Correct 22 ms 3368 KB Output is correct
31 Correct 23 ms 3416 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1908 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 6 ms 1160 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1880 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 432 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 436 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 424 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 436 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 348 KB Output is correct
37 Correct 1 ms 544 KB Output is correct
38 Correct 5 ms 860 KB Output is correct
39 Correct 1 ms 436 KB Output is correct
40 Correct 2 ms 344 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 4 ms 856 KB Output is correct
43 Correct 3 ms 860 KB Output is correct
44 Correct 4 ms 984 KB Output is correct
45 Correct 6 ms 1116 KB Output is correct
46 Correct 6 ms 1004 KB Output is correct
47 Correct 6 ms 1088 KB Output is correct
48 Correct 1 ms 604 KB Output is correct
49 Correct 3 ms 616 KB Output is correct
50 Correct 3 ms 692 KB Output is correct
51 Correct 4 ms 692 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 3 ms 600 KB Output is correct
54 Correct 3 ms 860 KB Output is correct
55 Correct 4 ms 860 KB Output is correct
56 Correct 2 ms 616 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 3 ms 604 KB Output is correct
59 Correct 3 ms 604 KB Output is correct
60 Correct 3 ms 732 KB Output is correct
61 Correct 5 ms 1116 KB Output is correct
62 Correct 1 ms 600 KB Output is correct
63 Correct 4 ms 688 KB Output is correct
64 Correct 3 ms 600 KB Output is correct
65 Correct 3 ms 604 KB Output is correct
66 Correct 3 ms 860 KB Output is correct
67 Correct 4 ms 860 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Correct 0 ms 436 KB Output is correct
72 Correct 2 ms 600 KB Output is correct
73 Correct 2 ms 604 KB Output is correct
74 Correct 2 ms 604 KB Output is correct
75 Correct 2 ms 604 KB Output is correct
76 Correct 3 ms 604 KB Output is correct
77 Correct 2 ms 664 KB Output is correct
78 Correct 3 ms 856 KB Output is correct
79 Correct 4 ms 860 KB Output is correct
80 Correct 5 ms 860 KB Output is correct
81 Correct 4 ms 860 KB Output is correct
82 Correct 1 ms 604 KB Output is correct
83 Correct 3 ms 604 KB Output is correct
84 Correct 3 ms 860 KB Output is correct
85 Correct 4 ms 900 KB Output is correct
86 Correct 1 ms 604 KB Output is correct
87 Correct 3 ms 604 KB Output is correct
88 Correct 4 ms 808 KB Output is correct
89 Correct 6 ms 1116 KB Output is correct
90 Correct 10 ms 1716 KB Output is correct
91 Correct 12 ms 1888 KB Output is correct
92 Correct 13 ms 2076 KB Output is correct
93 Correct 6 ms 1120 KB Output is correct
94 Correct 11 ms 1888 KB Output is correct
95 Correct 15 ms 1888 KB Output is correct
96 Correct 12 ms 1888 KB Output is correct
97 Correct 16 ms 2656 KB Output is correct
98 Correct 22 ms 3164 KB Output is correct
99 Correct 22 ms 3368 KB Output is correct
100 Correct 23 ms 3416 KB Output is correct
101 Correct 0 ms 348 KB Output is correct
102 Correct 0 ms 348 KB Output is correct
103 Correct 11 ms 1908 KB Output is correct
104 Correct 0 ms 344 KB Output is correct
105 Correct 2 ms 600 KB Output is correct
106 Correct 3 ms 600 KB Output is correct
107 Correct 1 ms 604 KB Output is correct
108 Correct 1 ms 604 KB Output is correct
109 Correct 6 ms 1160 KB Output is correct
110 Correct 6 ms 1116 KB Output is correct
111 Correct 11 ms 1880 KB Output is correct
112 Correct 0 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 16 ms 2652 KB Output is correct
115 Correct 4 ms 856 KB Output is correct
116 Correct 1 ms 604 KB Output is correct
117 Correct 12 ms 1884 KB Output is correct
118 Correct 8 ms 1368 KB Output is correct
119 Correct 20 ms 2908 KB Output is correct
120 Correct 20 ms 3084 KB Output is correct
121 Correct 20 ms 3016 KB Output is correct
122 Correct 20 ms 2908 KB Output is correct
123 Correct 11 ms 1880 KB Output is correct
124 Correct 17 ms 2640 KB Output is correct
125 Correct 20 ms 2908 KB Output is correct
126 Correct 20 ms 2904 KB Output is correct
127 Correct 22 ms 3292 KB Output is correct
128 Correct 27 ms 3520 KB Output is correct