Submission #293308

# Submission time Handle Problem Language Result Execution time Memory
293308 2020-09-07T20:59:54 Z TheRedstar Vision Program (IOI19_vision) C++14
100 / 100
62 ms 4500 KB
#include "vision.h"

#include <bits/stdc++.h>


using namespace std;


typedef vector<int> vi;


int W,H,K;
int nMEM, nDIAG, nDIF, nBAND;

int memory(int x, int y) {return x+W*y;}
int diag1(int i) {return nMEM+i +1;}
int diag2(int i) {return diag1(nDIAG) +i;}
int dif1(int i) {return diag2(nDIAG) +i;}
int dif2(int i) {return dif1(nDIF) +i;}
int band1(int i) {return dif2(nDIF) +i;}
int band2(int i) {return band1(nBAND) +i;}



void construct_network(int h, int w, int k) {
	W=w;
	H=h;
	K=k;
	
	nMEM=W*H;
	nDIAG=W+H-1;
	nDIF=nDIAG-K;
	nBAND=nDIF;
	
	vi Ns;
	
	int always_false=add_xor({0,0});
	
	//cout << "diag1\n";
	//diag1
	int startx,starty;
	for(int i=0; i<nDIAG; i++) {
		Ns={};
		starty=H-1-i;
		startx=0-min(0,starty);
		starty=max(0,starty);
		for(int j=0; startx+j<W and starty+j<H; j++)
			Ns.push_back(memory(startx+j, starty+j));

		add_or(Ns);	
	}
	
	//cout << "diag2\n";
	//diag2
	for(int i=0; i<nDIAG; i++) {
		Ns={};
		starty=H-1-i;
		startx=W-1+min(0,starty);
		starty=max(0,starty);
		for(int j=0; startx-j>=0 and starty+j<H; j++)
			Ns.push_back(memory(startx-j, starty+j));

		add_or(Ns);	
	}
	
	//cout << "dif1\n";
	//dif1
	for(int i=0; i<nDIF; i++) {
		Ns={diag1(i),diag1(i+K)};
		add_and(Ns);	
	}
	
	//cout << "dif2\n";
	//dif2
	for(int i=0; i<nDIF; i++) {
		Ns={diag2(i),diag2(i+K)};
		add_and(Ns);	
	}
	
	//cout << "band1\n";
	//band1
	for(int i=0; i<nBAND; i++) {
		Ns={always_false};
		for(int j=-1; i+j>=0; j--) Ns.push_back(diag1(i+j));
		for(int j=K+1; i+j<nDIAG; j++) Ns.push_back(diag1(i+j));
		add_or(Ns); // add not(and(band))
	}
	
	//cout << "band2\n";
	//band2
	for(int i=0; i<nBAND; i++) {
		Ns={always_false};
		for(int j=-1; i+j>=0; j--) Ns.push_back(diag2(i+j));
		for(int j=K+1; i+j<nDIAG; j++) Ns.push_back(diag2(i+j));
		add_or(Ns); // add not(and(band))
	}
	
	//cout << "dif1 or\n";
	//or for dif1
	Ns={};
	for(int i=0; i<nDIF; i++) Ns.push_back(dif1(i));
	int or_dif1=add_or(Ns);
	
	//cout << "dif2 or\n";
	//or for dif2
	Ns={};
	for(int i=0; i<nDIF; i++) Ns.push_back(dif2(i));
	int or_dif2=add_or(Ns);
	
	//cout << "band1 or\n";
	//not and band1
	Ns={};
	for(int i=0; i<nBAND; i++) Ns.push_back(band1(i));
	int or_band1=add_not(add_and(Ns));
	
	//cout << "band2 or\n";
	//not and band1
	Ns={};
	for(int i=0; i<nBAND; i++) Ns.push_back(band2(i));
	int or_band2=add_not(add_and(Ns));
	
	//cout << "final\n";
	add_or({add_and({or_dif1,or_band2}), add_and({or_dif2,or_band1})});
	
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 288 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 288 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 288 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 288 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 9 ms 1024 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 7 ms 896 KB Output is correct
42 Correct 2 ms 544 KB Output is correct
43 Correct 13 ms 1408 KB Output is correct
44 Correct 9 ms 1024 KB Output is correct
45 Correct 6 ms 768 KB Output is correct
46 Correct 4 ms 512 KB Output is correct
47 Correct 4 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1024 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 10 ms 1056 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 10 ms 1024 KB Output is correct
10 Correct 7 ms 768 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 10 ms 1024 KB Output is correct
16 Correct 6 ms 768 KB Output is correct
17 Correct 4 ms 512 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 4 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 11 ms 1024 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 4 ms 640 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 12 ms 1024 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 15 ms 1024 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 27 ms 2552 KB Output is correct
21 Correct 15 ms 1536 KB Output is correct
22 Correct 8 ms 896 KB Output is correct
23 Correct 5 ms 768 KB Output is correct
24 Correct 27 ms 2560 KB Output is correct
25 Correct 11 ms 1280 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 62 ms 4472 KB Output is correct
28 Correct 32 ms 3064 KB Output is correct
29 Correct 21 ms 2040 KB Output is correct
30 Correct 13 ms 1408 KB Output is correct
31 Correct 10 ms 1152 KB Output is correct
32 Correct 0 ms 256 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4344 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 7 ms 768 KB Output is correct
4 Correct 10 ms 1024 KB Output is correct
5 Correct 13 ms 1024 KB Output is correct
6 Correct 10 ms 1024 KB Output is correct
7 Correct 28 ms 2556 KB Output is correct
8 Correct 27 ms 2560 KB Output is correct
9 Correct 49 ms 4344 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 2 ms 288 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 9 ms 1024 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 7 ms 896 KB Output is correct
42 Correct 2 ms 544 KB Output is correct
43 Correct 13 ms 1408 KB Output is correct
44 Correct 9 ms 1024 KB Output is correct
45 Correct 6 ms 768 KB Output is correct
46 Correct 4 ms 512 KB Output is correct
47 Correct 4 ms 512 KB Output is correct
48 Correct 15 ms 1024 KB Output is correct
49 Correct 3 ms 512 KB Output is correct
50 Correct 5 ms 512 KB Output is correct
51 Correct 1 ms 384 KB Output is correct
52 Correct 10 ms 1056 KB Output is correct
53 Correct 5 ms 640 KB Output is correct
54 Correct 2 ms 544 KB Output is correct
55 Correct 1 ms 384 KB Output is correct
56 Correct 10 ms 1024 KB Output is correct
57 Correct 7 ms 768 KB Output is correct
58 Correct 3 ms 512 KB Output is correct
59 Correct 3 ms 512 KB Output is correct
60 Correct 2 ms 384 KB Output is correct
61 Correct 1 ms 384 KB Output is correct
62 Correct 10 ms 1024 KB Output is correct
63 Correct 6 ms 768 KB Output is correct
64 Correct 4 ms 512 KB Output is correct
65 Correct 3 ms 512 KB Output is correct
66 Correct 2 ms 384 KB Output is correct
67 Correct 1 ms 384 KB Output is correct
68 Correct 0 ms 256 KB Output is correct
69 Correct 1 ms 288 KB Output is correct
70 Correct 1 ms 256 KB Output is correct
71 Correct 1 ms 256 KB Output is correct
72 Correct 5 ms 640 KB Output is correct
73 Correct 4 ms 512 KB Output is correct
74 Correct 4 ms 512 KB Output is correct
75 Correct 2 ms 384 KB Output is correct
76 Correct 1 ms 384 KB Output is correct
77 Correct 11 ms 1024 KB Output is correct
78 Correct 6 ms 768 KB Output is correct
79 Correct 4 ms 640 KB Output is correct
80 Correct 3 ms 512 KB Output is correct
81 Correct 2 ms 384 KB Output is correct
82 Correct 12 ms 1024 KB Output is correct
83 Correct 5 ms 640 KB Output is correct
84 Correct 2 ms 384 KB Output is correct
85 Correct 1 ms 384 KB Output is correct
86 Correct 15 ms 1024 KB Output is correct
87 Correct 3 ms 512 KB Output is correct
88 Correct 1 ms 384 KB Output is correct
89 Correct 27 ms 2552 KB Output is correct
90 Correct 15 ms 1536 KB Output is correct
91 Correct 8 ms 896 KB Output is correct
92 Correct 5 ms 768 KB Output is correct
93 Correct 27 ms 2560 KB Output is correct
94 Correct 11 ms 1280 KB Output is correct
95 Correct 5 ms 768 KB Output is correct
96 Correct 62 ms 4472 KB Output is correct
97 Correct 32 ms 3064 KB Output is correct
98 Correct 21 ms 2040 KB Output is correct
99 Correct 13 ms 1408 KB Output is correct
100 Correct 10 ms 1152 KB Output is correct
101 Correct 0 ms 256 KB Output is correct
102 Correct 1 ms 256 KB Output is correct
103 Correct 51 ms 4344 KB Output is correct
104 Correct 0 ms 256 KB Output is correct
105 Correct 7 ms 768 KB Output is correct
106 Correct 10 ms 1024 KB Output is correct
107 Correct 13 ms 1024 KB Output is correct
108 Correct 10 ms 1024 KB Output is correct
109 Correct 28 ms 2556 KB Output is correct
110 Correct 27 ms 2560 KB Output is correct
111 Correct 49 ms 4344 KB Output is correct
112 Correct 0 ms 256 KB Output is correct
113 Correct 0 ms 256 KB Output is correct
114 Correct 32 ms 3064 KB Output is correct
115 Correct 1 ms 384 KB Output is correct
116 Correct 15 ms 1024 KB Output is correct
117 Correct 6 ms 768 KB Output is correct
118 Correct 32 ms 2048 KB Output is correct
119 Correct 20 ms 1920 KB Output is correct
120 Correct 20 ms 1920 KB Output is correct
121 Correct 20 ms 2040 KB Output is correct
122 Correct 20 ms 1920 KB Output is correct
123 Correct 59 ms 4500 KB Output is correct
124 Correct 32 ms 3064 KB Output is correct
125 Correct 20 ms 2040 KB Output is correct
126 Correct 20 ms 2048 KB Output is correct
127 Correct 14 ms 1408 KB Output is correct
128 Correct 10 ms 1152 KB Output is correct