Submission #813414

# Submission time Handle Problem Language Result Execution time Memory
813414 2023-08-07T17:31:47 Z fatemetmhr Vision Program (IOI19_vision) C++17
100 / 100
29 ms 5452 KB
// Comment!


#include "vision.h"
#include <bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


typedef long long ll;

#define mp     make_pair
#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second

const int maxn5 = 2e5 + 10;

vector <int> ns, av[2], av2[2];
int h, w, dim[2][maxn5], xdim[2][maxn5];


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

	h = H;
	w = W;
	memset(dim, -1, sizeof dim);
	for(int sum = 0; sum <= h + w - 2; sum++){
		ns.clear();
		for(int i = 0; i < h; i++){
			int j = sum - i;
			if(j >= 0 && j < w)
				ns.pb(i * w + j);
		}
		sort(all(ns));
		dim[0][sum] = add_or(ns);
		xdim[0][sum] = add_xor(ns);
	}
	for(int sum = -(h - 1); sum < w; sum++){
		ns.clear();
		for(int i = 0; i < h; i++){
			int j = sum + i;
			if(j >= 0 && j < w)
				ns.pb(i * w + j);
		}
		sort(all(ns));
		dim[1][sum + h - 1] = add_or(ns);
		xdim[1][sum + h - 1] = add_xor(ns);
	}
	int eqk, eq[2], lestk, les[2];
	for(int sum = 0; sum <= h + w - 2; sum++){
		for(int tt = 0; tt < 2; tt++){
			if(sum + k <= h + w - 2){
				ns = {dim[tt][sum], dim[tt][sum + k]};
				av[tt].pb(add_and(ns));	
			}
			ns.clear();
			for(int x = 1; x <= k; x++) if(x + sum <= h + w - 2)
				ns.pb(dim[tt][x + sum]);
			int cur = -1;
			if(ns.size()){
				cur = add_or(ns);
				ns = {dim[tt][sum], cur};
				cur = add_and(ns);
			}
			int cur2 = add_not(xdim[tt][sum]);
			ns = {cur2, dim[tt][sum]};
			cur2 = add_and(ns);
			if(cur == -1)
				av2[tt].pb(cur2);
			else{
				ns = {cur, cur2};
				av2[tt].pb(add_or(ns));
			}
		}
	}
	for(int tt = 0; tt < 2; tt++){
		sort(all(av[tt]));
		eq[tt] = add_or(av[tt]);
		sort(all(av2[tt]));
		les[tt] = add_or(av2[tt]);
	}
	ns = {eq[0], eq[1]};
	eqk = add_or(ns);
	ns = {les[0], les[1]};
	lestk = add_and(ns);
	ns = {eqk, lestk};
	//cout << eq[0] + 1 << ' ' << eq[1] + 1 << ' ' << eqk + 1 << endl;
	//cout << les[0] + 1 << ' ' << les[1] + 1 << ' ' << lestk + 1 << endl;
	add_and(ns);
}














# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1856 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1856 KB Output is correct
15 Correct 1 ms 1852 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1844 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1856 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1856 KB Output is correct
15 Correct 1 ms 1852 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1844 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1852 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 2 ms 1848 KB Output is correct
26 Correct 2 ms 1876 KB Output is correct
27 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1856 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1856 KB Output is correct
15 Correct 1 ms 1852 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1844 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1852 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 2 ms 1848 KB Output is correct
26 Correct 2 ms 1876 KB Output is correct
27 Correct 1 ms 1876 KB Output is correct
28 Correct 3 ms 1876 KB Output is correct
29 Correct 2 ms 1852 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 1 ms 1876 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 2 ms 1980 KB Output is correct
34 Correct 2 ms 1984 KB Output is correct
35 Correct 2 ms 2004 KB Output is correct
36 Correct 2 ms 2004 KB Output is correct
37 Correct 2 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1856 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1856 KB Output is correct
15 Correct 1 ms 1852 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1844 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1852 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 2 ms 1848 KB Output is correct
26 Correct 2 ms 1876 KB Output is correct
27 Correct 1 ms 1876 KB Output is correct
28 Correct 3 ms 1876 KB Output is correct
29 Correct 2 ms 1852 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 1 ms 1876 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 2 ms 1980 KB Output is correct
34 Correct 2 ms 1984 KB Output is correct
35 Correct 2 ms 2004 KB Output is correct
36 Correct 2 ms 2004 KB Output is correct
37 Correct 2 ms 2004 KB Output is correct
38 Correct 8 ms 2640 KB Output is correct
39 Correct 2 ms 2004 KB Output is correct
40 Correct 2 ms 1980 KB Output is correct
41 Correct 3 ms 2232 KB Output is correct
42 Correct 7 ms 2368 KB Output is correct
43 Correct 5 ms 2388 KB Output is correct
44 Correct 8 ms 2568 KB Output is correct
45 Correct 7 ms 2644 KB Output is correct
46 Correct 7 ms 2772 KB Output is correct
47 Correct 8 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2132 KB Output is correct
2 Correct 4 ms 2240 KB Output is correct
3 Correct 4 ms 2260 KB Output is correct
4 Correct 5 ms 2368 KB Output is correct
5 Correct 3 ms 2108 KB Output is correct
6 Correct 4 ms 2260 KB Output is correct
7 Correct 4 ms 2388 KB Output is correct
8 Correct 5 ms 2388 KB Output is correct
9 Correct 2 ms 2132 KB Output is correct
10 Correct 3 ms 2260 KB Output is correct
11 Correct 4 ms 2260 KB Output is correct
12 Correct 5 ms 2260 KB Output is correct
13 Correct 5 ms 2388 KB Output is correct
14 Correct 5 ms 2388 KB Output is correct
15 Correct 2 ms 2132 KB Output is correct
16 Correct 4 ms 2260 KB Output is correct
17 Correct 4 ms 2260 KB Output is correct
18 Correct 4 ms 2260 KB Output is correct
19 Correct 5 ms 2360 KB Output is correct
20 Correct 5 ms 2364 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1852 KB Output is correct
3 Correct 3 ms 2132 KB Output is correct
4 Correct 3 ms 2132 KB Output is correct
5 Correct 3 ms 2132 KB Output is correct
6 Correct 5 ms 2132 KB Output is correct
7 Correct 3 ms 2260 KB Output is correct
8 Correct 4 ms 2260 KB Output is correct
9 Correct 4 ms 2360 KB Output is correct
10 Correct 5 ms 2480 KB Output is correct
11 Correct 6 ms 2516 KB Output is correct
12 Correct 6 ms 2516 KB Output is correct
13 Correct 2 ms 2132 KB Output is correct
14 Correct 4 ms 2252 KB Output is correct
15 Correct 5 ms 2388 KB Output is correct
16 Correct 6 ms 2388 KB Output is correct
17 Correct 2 ms 2104 KB Output is correct
18 Correct 4 ms 2260 KB Output is correct
19 Correct 5 ms 2360 KB Output is correct
20 Correct 8 ms 2996 KB Output is correct
21 Correct 12 ms 3384 KB Output is correct
22 Correct 14 ms 3664 KB Output is correct
23 Correct 15 ms 3764 KB Output is correct
24 Correct 8 ms 3024 KB Output is correct
25 Correct 13 ms 3640 KB Output is correct
26 Correct 14 ms 3756 KB Output is correct
27 Correct 15 ms 3920 KB Output is correct
28 Correct 20 ms 4572 KB Output is correct
29 Correct 29 ms 4996 KB Output is correct
30 Correct 28 ms 5308 KB Output is correct
31 Correct 26 ms 5320 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 1 ms 1848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3908 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 3 ms 2112 KB Output is correct
4 Correct 4 ms 2236 KB Output is correct
5 Correct 2 ms 2132 KB Output is correct
6 Correct 2 ms 2104 KB Output is correct
7 Correct 8 ms 3024 KB Output is correct
8 Correct 8 ms 3004 KB Output is correct
9 Correct 18 ms 3896 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1856 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1856 KB Output is correct
15 Correct 1 ms 1852 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1844 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 1 ms 1852 KB Output is correct
21 Correct 1 ms 1876 KB Output is correct
22 Correct 1 ms 1876 KB Output is correct
23 Correct 1 ms 1876 KB Output is correct
24 Correct 1 ms 1876 KB Output is correct
25 Correct 2 ms 1848 KB Output is correct
26 Correct 2 ms 1876 KB Output is correct
27 Correct 1 ms 1876 KB Output is correct
28 Correct 3 ms 1876 KB Output is correct
29 Correct 2 ms 1852 KB Output is correct
30 Correct 1 ms 1876 KB Output is correct
31 Correct 1 ms 1876 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 2 ms 1980 KB Output is correct
34 Correct 2 ms 1984 KB Output is correct
35 Correct 2 ms 2004 KB Output is correct
36 Correct 2 ms 2004 KB Output is correct
37 Correct 2 ms 2004 KB Output is correct
38 Correct 8 ms 2640 KB Output is correct
39 Correct 2 ms 2004 KB Output is correct
40 Correct 2 ms 1980 KB Output is correct
41 Correct 3 ms 2232 KB Output is correct
42 Correct 7 ms 2368 KB Output is correct
43 Correct 5 ms 2388 KB Output is correct
44 Correct 8 ms 2568 KB Output is correct
45 Correct 7 ms 2644 KB Output is correct
46 Correct 7 ms 2772 KB Output is correct
47 Correct 8 ms 2772 KB Output is correct
48 Correct 2 ms 2132 KB Output is correct
49 Correct 4 ms 2240 KB Output is correct
50 Correct 4 ms 2260 KB Output is correct
51 Correct 5 ms 2368 KB Output is correct
52 Correct 3 ms 2108 KB Output is correct
53 Correct 4 ms 2260 KB Output is correct
54 Correct 4 ms 2388 KB Output is correct
55 Correct 5 ms 2388 KB Output is correct
56 Correct 2 ms 2132 KB Output is correct
57 Correct 3 ms 2260 KB Output is correct
58 Correct 4 ms 2260 KB Output is correct
59 Correct 5 ms 2260 KB Output is correct
60 Correct 5 ms 2388 KB Output is correct
61 Correct 5 ms 2388 KB Output is correct
62 Correct 2 ms 2132 KB Output is correct
63 Correct 4 ms 2260 KB Output is correct
64 Correct 4 ms 2260 KB Output is correct
65 Correct 4 ms 2260 KB Output is correct
66 Correct 5 ms 2360 KB Output is correct
67 Correct 5 ms 2364 KB Output is correct
68 Correct 1 ms 1876 KB Output is correct
69 Correct 1 ms 1876 KB Output is correct
70 Correct 1 ms 1876 KB Output is correct
71 Correct 1 ms 1852 KB Output is correct
72 Correct 3 ms 2132 KB Output is correct
73 Correct 3 ms 2132 KB Output is correct
74 Correct 3 ms 2132 KB Output is correct
75 Correct 5 ms 2132 KB Output is correct
76 Correct 3 ms 2260 KB Output is correct
77 Correct 4 ms 2260 KB Output is correct
78 Correct 4 ms 2360 KB Output is correct
79 Correct 5 ms 2480 KB Output is correct
80 Correct 6 ms 2516 KB Output is correct
81 Correct 6 ms 2516 KB Output is correct
82 Correct 2 ms 2132 KB Output is correct
83 Correct 4 ms 2252 KB Output is correct
84 Correct 5 ms 2388 KB Output is correct
85 Correct 6 ms 2388 KB Output is correct
86 Correct 2 ms 2104 KB Output is correct
87 Correct 4 ms 2260 KB Output is correct
88 Correct 5 ms 2360 KB Output is correct
89 Correct 8 ms 2996 KB Output is correct
90 Correct 12 ms 3384 KB Output is correct
91 Correct 14 ms 3664 KB Output is correct
92 Correct 15 ms 3764 KB Output is correct
93 Correct 8 ms 3024 KB Output is correct
94 Correct 13 ms 3640 KB Output is correct
95 Correct 14 ms 3756 KB Output is correct
96 Correct 15 ms 3920 KB Output is correct
97 Correct 20 ms 4572 KB Output is correct
98 Correct 29 ms 4996 KB Output is correct
99 Correct 28 ms 5308 KB Output is correct
100 Correct 26 ms 5320 KB Output is correct
101 Correct 1 ms 1876 KB Output is correct
102 Correct 1 ms 1848 KB Output is correct
103 Correct 15 ms 3908 KB Output is correct
104 Correct 1 ms 1876 KB Output is correct
105 Correct 3 ms 2112 KB Output is correct
106 Correct 4 ms 2236 KB Output is correct
107 Correct 2 ms 2132 KB Output is correct
108 Correct 2 ms 2104 KB Output is correct
109 Correct 8 ms 3024 KB Output is correct
110 Correct 8 ms 3004 KB Output is correct
111 Correct 18 ms 3896 KB Output is correct
112 Correct 1 ms 1876 KB Output is correct
113 Correct 1 ms 1876 KB Output is correct
114 Correct 20 ms 4560 KB Output is correct
115 Correct 5 ms 2388 KB Output is correct
116 Correct 2 ms 2132 KB Output is correct
117 Correct 15 ms 3760 KB Output is correct
118 Correct 10 ms 3152 KB Output is correct
119 Correct 22 ms 4964 KB Output is correct
120 Correct 23 ms 4972 KB Output is correct
121 Correct 23 ms 5016 KB Output is correct
122 Correct 24 ms 4936 KB Output is correct
123 Correct 15 ms 3900 KB Output is correct
124 Correct 20 ms 4592 KB Output is correct
125 Correct 28 ms 4992 KB Output is correct
126 Correct 23 ms 5064 KB Output is correct
127 Correct 25 ms 5288 KB Output is correct
128 Correct 26 ms 5452 KB Output is correct