Submission #593016

# Submission time Handle Problem Language Result Execution time Memory
593016 2022-07-10T07:42:41 Z Lucpp Vision Program (IOI19_vision) C++17
100 / 100
33 ms 2076 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

int solveDiv(int N, int start, int K){
	vector<int> v;
	for(int i = 0; i < min(K, N-K); i++){
		vector<int> w;
		for(int j = i; j < N; j += K) w.push_back(start+j);
		v.push_back(add_xor(w));
	}
	for(int i = N-K; i < K; i++) v.push_back(start+i);
	return add_not(add_or(v));
}

bool isPrimePower(int i){
	int div = -1;
	for(int j = 2; j < i; j++){
		if(i % j == 0){
			if(div == -1) div = j;
			else if(j % div != 0) return false;
		}
	}
	return true;
}

int solve1D(int N, vector<int> mult, int K){
	vector<int> good, bad;
	for(int i = 1; i < N; i++){
		if(!isPrimePower(i)) continue;
		if(K % i == 0) good.push_back(mult[i]);
		else bad.push_back(mult[i]);
	}
	int a = -1, b = -1;
	if(!bad.empty()) a = add_not(add_or(bad));
	b = add_and(good);
	if(a == -1) return b;
	return add_and({a, b});
}

void construct_network(int H, int W, int K) {
	int row_start = -1, col_start = -1;
	for(int i = 0; i < H; i++){
		vector<int> v;
		for(int j = 0; j < W; j++) v.push_back(i*W+j);
		int x = add_or(v);
		if(i == 0) row_start = x;
	}
	for(int j = 0; j < W; j++){
		vector<int> v;
		for(int i = 0; i < H; i++) v.emplace_back(i*W+j);
		int x = add_or(v);
		if(j == 0) col_start = x;
	}
	vector<int> row(H), col(W);
	{ // k = 0
		vector<int> v;
		for(int i = 0; i < H; i++) v.push_back(row_start+i);
		row[0] = add_xor(v);
		v.clear();
		for(int i = 0; i < W; i++) v.push_back(col_start+i);
		col[0] = add_xor(v);
	}
	vector<int> multR(H), multC(W);
	for(int k = 1; k < H; k++){
		if(!isPrimePower(k)) continue;
		multR[k] = solveDiv(H, row_start, k);
	}
	for(int k = 1; k < W; k++){
		if(!isPrimePower(k)) continue;
		multC[k] = solveDiv(W, col_start, k);
	}
	for(int k = 1; k < H; k++){
		row[k] = solve1D(H, multR, k);
	}
	for(int k = 1; k < W; k++){
		col[k] = solve1D(W, multC, k);
	}
	vector<int> todo;
	for(int kr = 0; kr < H; kr++){
		int kc = K-kr;
		if(kc >= 0 && kc < W){
			todo.push_back(add_and({row[kr], col[kc]}));
		}
	}
	add_or(todo);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 304 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 304 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 304 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 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 1 ms 212 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 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 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 304 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 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 1 ms 212 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 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 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 7 ms 816 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 3 ms 340 KB Output is correct
41 Correct 4 ms 556 KB Output is correct
42 Correct 4 ms 596 KB Output is correct
43 Correct 8 ms 744 KB Output is correct
44 Correct 7 ms 724 KB Output is correct
45 Correct 7 ms 724 KB Output is correct
46 Correct 7 ms 724 KB Output is correct
47 Correct 7 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 752 KB Output is correct
2 Correct 11 ms 724 KB Output is correct
3 Correct 11 ms 748 KB Output is correct
4 Correct 12 ms 724 KB Output is correct
5 Correct 12 ms 728 KB Output is correct
6 Correct 12 ms 756 KB Output is correct
7 Correct 11 ms 724 KB Output is correct
8 Correct 11 ms 736 KB Output is correct
9 Correct 12 ms 664 KB Output is correct
10 Correct 12 ms 724 KB Output is correct
11 Correct 12 ms 724 KB Output is correct
12 Correct 12 ms 752 KB Output is correct
13 Correct 12 ms 716 KB Output is correct
14 Correct 12 ms 700 KB Output is correct
15 Correct 12 ms 760 KB Output is correct
16 Correct 11 ms 724 KB Output is correct
17 Correct 12 ms 724 KB Output is correct
18 Correct 13 ms 744 KB Output is correct
19 Correct 12 ms 748 KB Output is correct
20 Correct 12 ms 704 KB Output is correct
21 Correct 0 ms 224 KB Output is correct
22 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 3 ms 468 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 4 ms 444 KB Output is correct
8 Correct 7 ms 716 KB Output is correct
9 Correct 8 ms 724 KB Output is correct
10 Correct 9 ms 724 KB Output is correct
11 Correct 6 ms 724 KB Output is correct
12 Correct 7 ms 716 KB Output is correct
13 Correct 11 ms 724 KB Output is correct
14 Correct 12 ms 712 KB Output is correct
15 Correct 11 ms 740 KB Output is correct
16 Correct 12 ms 724 KB Output is correct
17 Correct 12 ms 724 KB Output is correct
18 Correct 12 ms 716 KB Output is correct
19 Correct 12 ms 744 KB Output is correct
20 Correct 17 ms 1232 KB Output is correct
21 Correct 18 ms 1360 KB Output is correct
22 Correct 17 ms 1360 KB Output is correct
23 Correct 18 ms 1300 KB Output is correct
24 Correct 17 ms 1260 KB Output is correct
25 Correct 17 ms 1268 KB Output is correct
26 Correct 17 ms 1320 KB Output is correct
27 Correct 30 ms 1992 KB Output is correct
28 Correct 33 ms 1956 KB Output is correct
29 Correct 30 ms 1964 KB Output is correct
30 Correct 30 ms 2056 KB Output is correct
31 Correct 30 ms 2068 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2024 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 8 ms 620 KB Output is correct
5 Correct 11 ms 744 KB Output is correct
6 Correct 11 ms 724 KB Output is correct
7 Correct 18 ms 1332 KB Output is correct
8 Correct 17 ms 1264 KB Output is correct
9 Correct 30 ms 2056 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 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 304 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 300 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 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 1 ms 212 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 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 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 7 ms 816 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 3 ms 340 KB Output is correct
41 Correct 4 ms 556 KB Output is correct
42 Correct 4 ms 596 KB Output is correct
43 Correct 8 ms 744 KB Output is correct
44 Correct 7 ms 724 KB Output is correct
45 Correct 7 ms 724 KB Output is correct
46 Correct 7 ms 724 KB Output is correct
47 Correct 7 ms 724 KB Output is correct
48 Correct 13 ms 752 KB Output is correct
49 Correct 11 ms 724 KB Output is correct
50 Correct 11 ms 748 KB Output is correct
51 Correct 12 ms 724 KB Output is correct
52 Correct 12 ms 728 KB Output is correct
53 Correct 12 ms 756 KB Output is correct
54 Correct 11 ms 724 KB Output is correct
55 Correct 11 ms 736 KB Output is correct
56 Correct 12 ms 664 KB Output is correct
57 Correct 12 ms 724 KB Output is correct
58 Correct 12 ms 724 KB Output is correct
59 Correct 12 ms 752 KB Output is correct
60 Correct 12 ms 716 KB Output is correct
61 Correct 12 ms 700 KB Output is correct
62 Correct 12 ms 760 KB Output is correct
63 Correct 11 ms 724 KB Output is correct
64 Correct 12 ms 724 KB Output is correct
65 Correct 13 ms 744 KB Output is correct
66 Correct 12 ms 748 KB Output is correct
67 Correct 12 ms 704 KB Output is correct
68 Correct 0 ms 224 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 3 ms 468 KB Output is correct
73 Correct 3 ms 468 KB Output is correct
74 Correct 4 ms 468 KB Output is correct
75 Correct 3 ms 468 KB Output is correct
76 Correct 4 ms 444 KB Output is correct
77 Correct 7 ms 716 KB Output is correct
78 Correct 8 ms 724 KB Output is correct
79 Correct 9 ms 724 KB Output is correct
80 Correct 6 ms 724 KB Output is correct
81 Correct 7 ms 716 KB Output is correct
82 Correct 11 ms 724 KB Output is correct
83 Correct 12 ms 712 KB Output is correct
84 Correct 11 ms 740 KB Output is correct
85 Correct 12 ms 724 KB Output is correct
86 Correct 12 ms 724 KB Output is correct
87 Correct 12 ms 716 KB Output is correct
88 Correct 12 ms 744 KB Output is correct
89 Correct 17 ms 1232 KB Output is correct
90 Correct 18 ms 1360 KB Output is correct
91 Correct 17 ms 1360 KB Output is correct
92 Correct 18 ms 1300 KB Output is correct
93 Correct 17 ms 1260 KB Output is correct
94 Correct 17 ms 1268 KB Output is correct
95 Correct 17 ms 1320 KB Output is correct
96 Correct 30 ms 1992 KB Output is correct
97 Correct 33 ms 1956 KB Output is correct
98 Correct 30 ms 1964 KB Output is correct
99 Correct 30 ms 2056 KB Output is correct
100 Correct 30 ms 2068 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 0 ms 212 KB Output is correct
103 Correct 31 ms 2024 KB Output is correct
104 Correct 0 ms 212 KB Output is correct
105 Correct 4 ms 468 KB Output is correct
106 Correct 8 ms 620 KB Output is correct
107 Correct 11 ms 744 KB Output is correct
108 Correct 11 ms 724 KB Output is correct
109 Correct 18 ms 1332 KB Output is correct
110 Correct 17 ms 1264 KB Output is correct
111 Correct 30 ms 2056 KB Output is correct
112 Correct 0 ms 212 KB Output is correct
113 Correct 0 ms 304 KB Output is correct
114 Correct 30 ms 2040 KB Output is correct
115 Correct 11 ms 668 KB Output is correct
116 Correct 11 ms 704 KB Output is correct
117 Correct 19 ms 1316 KB Output is correct
118 Correct 18 ms 1256 KB Output is correct
119 Correct 29 ms 1992 KB Output is correct
120 Correct 30 ms 1956 KB Output is correct
121 Correct 30 ms 1964 KB Output is correct
122 Correct 30 ms 1992 KB Output is correct
123 Correct 30 ms 1996 KB Output is correct
124 Correct 30 ms 1992 KB Output is correct
125 Correct 30 ms 2048 KB Output is correct
126 Correct 31 ms 2076 KB Output is correct
127 Correct 29 ms 1992 KB Output is correct
128 Correct 30 ms 2020 KB Output is correct