답안 #188179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
188179 2020-01-13T06:25:22 Z anonymous Vision Program (IOI19_vision) C++14
100 / 100
24 ms 2040 KB
#include "vision.h"
#include<iostream>
#define MAXN 205
using namespace std;
int p[10]={2,3,5,7,11,13,17,19}, P=8;
void construct_network(int H, int W, int K) {
	int HasR[MAXN], HasC[MAXN], modR[10][20], modC[10][20], modDR[10][20], modDC[10][20];
	vector<int> R[MAXN], C[MAXN], gR[10][20], gC[10][20];
	int distR[MAXN], distC[MAXN], filler;
	//generate whether each row and column has a black
	for (int r=0; r<H; r++) {
        for (int c=0; c<W; c++) {
            R[r].push_back(r*W+c);
            C[c].push_back(r*W+c);
        }
	}
	for (int i=0; i<H; i++) {
        HasR[i]=add_or(R[i]);
	}
	for (int i=0; i<W; i++) {
        HasC[i]=add_or(C[i]);
	}
	vector <int> Dummy;
	Dummy.push_back(HasC[0]);
	Dummy.push_back(add_not(HasC[0]));
	filler=add_and(Dummy); //guaranteed false
	if (H < 10) {
        for (int i=H; i<10; i++) {
            HasR[i]=filler;
        }
        H=10;
	}
	if (W < 10) {
        for (int i=W; i<10; i++) {
            HasC[i]=filler;
        }
        W=10;
	} //pad
	//generate position modulos
	for (int i=0; i<P; i++) {
        for (int r=0; r<H; r++) {
            gR[i][r%p[i]].push_back(HasR[r]);
        }
	}
	for (int i=0; i<P; i++) {
        for (int c=0; c<W; c++) {
            gC[i][c%p[i]].push_back(HasC[c]);
        }
	}
	for (int i=0; i<P; i++) {
        for (int mod=0; mod < p[i]; mod++) {
            gR[i][mod].push_back(filler);
            gC[i][mod].push_back(filler);
            modR[i][mod]=add_or(gR[i][mod]);
            modC[i][mod]=add_or(gC[i][mod]);
        }
	}
	//generate dist modulos
	for (int i=0; i<P; i++) {
        vector<int> Rpos;
        for (int mod=1; mod < p[i]; mod++) {
            vector <int> ask;
            for (int l=0; l<p[i]; l++) {
                vector <int> Pair;
                Pair.push_back(modR[i][l]);
                Pair.push_back(modR[i][(l+mod)%p[i]]);
                ask.push_back(add_and(Pair));
            }
            modDR[i][mod]=add_or(ask);
            Rpos.push_back(modDR[i][mod]);
        }
        modDR[i][0]=add_not(add_or(Rpos));
	}

	for (int i=0; i<P; i++) {
        vector<int> Cpos;
        for (int mod=1; mod < p[i]; mod++) {
            vector <int> ask;
            for (int l=0; l<p[i]; l++) {
                vector <int> Pair;
                Pair.push_back(modC[i][l]);
                Pair.push_back(modC[i][(l+mod)%p[i]]);
                ask.push_back(add_and(Pair));
            }
            modDC[i][mod]=add_or(ask);
            Cpos.push_back(modDC[i][mod]);
        }
        modDC[i][0]=add_not(add_or(Cpos));
	}
	//generate dists by CRT on dist modulos
	vector<int> Rlist, Clist;
	Rlist.push_back(filler);
	Clist.push_back(filler);
	for (int i=1; i<H; i++) {
        vector<int> ask;
        for (int j=0; j<P; j++) {
            ask.push_back(modDR[j][i%p[j]]);
        }
        distR[i]=add_and(ask);
        Rlist.push_back(distR[i]);
	}
	distR[0]=add_not(add_or(Rlist));
	for (int i=1; i<W; i++) {
        vector<int> ask;
        for (int j=0; j<P; j++) {
            ask.push_back(modDC[j][i%p[j]]);
        }
        distC[i]=add_and(ask);
        Clist.push_back(distC[i]);
	}
	distC[0]=add_not(add_or(Clist));
	//generate answer
	vector <int> Res;
	for (int i=0; i<=K; i++) {
        vector <int> ask;
        if (i < H && K-i < W) {
            ask.push_back(distR[i]);
            ask.push_back(distC[K-i]);
            Res.push_back(add_and(ask));
        }
	}
	add_or(Res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 4 ms 632 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 3 ms 652 KB Output is correct
10 Correct 4 ms 636 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 4 ms 632 KB Output is correct
17 Correct 16 ms 532 KB Output is correct
18 Correct 4 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 4 ms 632 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 3 ms 652 KB Output is correct
10 Correct 4 ms 636 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 4 ms 632 KB Output is correct
17 Correct 16 ms 532 KB Output is correct
18 Correct 4 ms 632 KB Output is correct
19 Correct 4 ms 596 KB Output is correct
20 Correct 3 ms 632 KB Output is correct
21 Correct 4 ms 632 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 4 ms 632 KB Output is correct
24 Correct 4 ms 632 KB Output is correct
25 Correct 4 ms 632 KB Output is correct
26 Correct 4 ms 620 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 4 ms 632 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 3 ms 652 KB Output is correct
10 Correct 4 ms 636 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 4 ms 632 KB Output is correct
17 Correct 16 ms 532 KB Output is correct
18 Correct 4 ms 632 KB Output is correct
19 Correct 4 ms 596 KB Output is correct
20 Correct 3 ms 632 KB Output is correct
21 Correct 4 ms 632 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 4 ms 632 KB Output is correct
24 Correct 4 ms 632 KB Output is correct
25 Correct 4 ms 632 KB Output is correct
26 Correct 4 ms 620 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
28 Correct 4 ms 660 KB Output is correct
29 Correct 5 ms 764 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 4 ms 628 KB Output is correct
32 Correct 4 ms 612 KB Output is correct
33 Correct 9 ms 760 KB Output is correct
34 Correct 4 ms 616 KB Output is correct
35 Correct 9 ms 760 KB Output is correct
36 Correct 4 ms 784 KB Output is correct
37 Correct 4 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 4 ms 632 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 3 ms 652 KB Output is correct
10 Correct 4 ms 636 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 4 ms 632 KB Output is correct
17 Correct 16 ms 532 KB Output is correct
18 Correct 4 ms 632 KB Output is correct
19 Correct 4 ms 596 KB Output is correct
20 Correct 3 ms 632 KB Output is correct
21 Correct 4 ms 632 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 4 ms 632 KB Output is correct
24 Correct 4 ms 632 KB Output is correct
25 Correct 4 ms 632 KB Output is correct
26 Correct 4 ms 620 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
28 Correct 4 ms 660 KB Output is correct
29 Correct 5 ms 764 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 4 ms 628 KB Output is correct
32 Correct 4 ms 612 KB Output is correct
33 Correct 9 ms 760 KB Output is correct
34 Correct 4 ms 616 KB Output is correct
35 Correct 9 ms 760 KB Output is correct
36 Correct 4 ms 784 KB Output is correct
37 Correct 4 ms 760 KB Output is correct
38 Correct 7 ms 992 KB Output is correct
39 Correct 4 ms 632 KB Output is correct
40 Correct 4 ms 632 KB Output is correct
41 Correct 5 ms 744 KB Output is correct
42 Correct 4 ms 780 KB Output is correct
43 Correct 7 ms 860 KB Output is correct
44 Correct 6 ms 888 KB Output is correct
45 Correct 8 ms 860 KB Output is correct
46 Correct 7 ms 888 KB Output is correct
47 Correct 6 ms 892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 3 ms 620 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 4 ms 632 KB Output is correct
11 Correct 4 ms 648 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 6 ms 632 KB Output is correct
17 Correct 16 ms 620 KB Output is correct
18 Correct 4 ms 632 KB Output is correct
19 Correct 5 ms 632 KB Output is correct
20 Correct 3 ms 608 KB Output is correct
21 Correct 2 ms 632 KB Output is correct
22 Correct 4 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 19 ms 760 KB Output is correct
5 Correct 5 ms 764 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 6 ms 760 KB Output is correct
9 Correct 9 ms 888 KB Output is correct
10 Correct 5 ms 760 KB Output is correct
11 Correct 4 ms 888 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 4 ms 632 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 4 ms 632 KB Output is correct
18 Correct 4 ms 632 KB Output is correct
19 Correct 4 ms 632 KB Output is correct
20 Correct 10 ms 1244 KB Output is correct
21 Correct 9 ms 1272 KB Output is correct
22 Correct 10 ms 1292 KB Output is correct
23 Correct 8 ms 1272 KB Output is correct
24 Correct 9 ms 1244 KB Output is correct
25 Correct 6 ms 1268 KB Output is correct
26 Correct 9 ms 1272 KB Output is correct
27 Correct 12 ms 1912 KB Output is correct
28 Correct 14 ms 1904 KB Output is correct
29 Correct 14 ms 2040 KB Output is correct
30 Correct 13 ms 1900 KB Output is correct
31 Correct 15 ms 1888 KB Output is correct
32 Correct 4 ms 632 KB Output is correct
33 Correct 4 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1860 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 6 ms 760 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 11 ms 1224 KB Output is correct
8 Correct 6 ms 1272 KB Output is correct
9 Correct 12 ms 1912 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 4 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 4 ms 632 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 3 ms 652 KB Output is correct
10 Correct 4 ms 636 KB Output is correct
11 Correct 4 ms 632 KB Output is correct
12 Correct 4 ms 632 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 632 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 4 ms 632 KB Output is correct
17 Correct 16 ms 532 KB Output is correct
18 Correct 4 ms 632 KB Output is correct
19 Correct 4 ms 596 KB Output is correct
20 Correct 3 ms 632 KB Output is correct
21 Correct 4 ms 632 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 4 ms 632 KB Output is correct
24 Correct 4 ms 632 KB Output is correct
25 Correct 4 ms 632 KB Output is correct
26 Correct 4 ms 620 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
28 Correct 4 ms 660 KB Output is correct
29 Correct 5 ms 764 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 4 ms 628 KB Output is correct
32 Correct 4 ms 612 KB Output is correct
33 Correct 9 ms 760 KB Output is correct
34 Correct 4 ms 616 KB Output is correct
35 Correct 9 ms 760 KB Output is correct
36 Correct 4 ms 784 KB Output is correct
37 Correct 4 ms 760 KB Output is correct
38 Correct 7 ms 992 KB Output is correct
39 Correct 4 ms 632 KB Output is correct
40 Correct 4 ms 632 KB Output is correct
41 Correct 5 ms 744 KB Output is correct
42 Correct 4 ms 780 KB Output is correct
43 Correct 7 ms 860 KB Output is correct
44 Correct 6 ms 888 KB Output is correct
45 Correct 8 ms 860 KB Output is correct
46 Correct 7 ms 888 KB Output is correct
47 Correct 6 ms 892 KB Output is correct
48 Correct 4 ms 632 KB Output is correct
49 Correct 5 ms 632 KB Output is correct
50 Correct 3 ms 620 KB Output is correct
51 Correct 5 ms 632 KB Output is correct
52 Correct 2 ms 636 KB Output is correct
53 Correct 4 ms 632 KB Output is correct
54 Correct 5 ms 632 KB Output is correct
55 Correct 4 ms 632 KB Output is correct
56 Correct 5 ms 632 KB Output is correct
57 Correct 4 ms 632 KB Output is correct
58 Correct 4 ms 648 KB Output is correct
59 Correct 5 ms 632 KB Output is correct
60 Correct 5 ms 632 KB Output is correct
61 Correct 4 ms 632 KB Output is correct
62 Correct 5 ms 632 KB Output is correct
63 Correct 6 ms 632 KB Output is correct
64 Correct 16 ms 620 KB Output is correct
65 Correct 4 ms 632 KB Output is correct
66 Correct 5 ms 632 KB Output is correct
67 Correct 3 ms 608 KB Output is correct
68 Correct 2 ms 632 KB Output is correct
69 Correct 4 ms 760 KB Output is correct
70 Correct 4 ms 632 KB Output is correct
71 Correct 5 ms 604 KB Output is correct
72 Correct 5 ms 760 KB Output is correct
73 Correct 19 ms 760 KB Output is correct
74 Correct 5 ms 764 KB Output is correct
75 Correct 5 ms 632 KB Output is correct
76 Correct 5 ms 632 KB Output is correct
77 Correct 6 ms 760 KB Output is correct
78 Correct 9 ms 888 KB Output is correct
79 Correct 5 ms 760 KB Output is correct
80 Correct 4 ms 888 KB Output is correct
81 Correct 3 ms 760 KB Output is correct
82 Correct 4 ms 632 KB Output is correct
83 Correct 4 ms 632 KB Output is correct
84 Correct 4 ms 632 KB Output is correct
85 Correct 5 ms 632 KB Output is correct
86 Correct 4 ms 632 KB Output is correct
87 Correct 4 ms 632 KB Output is correct
88 Correct 4 ms 632 KB Output is correct
89 Correct 10 ms 1244 KB Output is correct
90 Correct 9 ms 1272 KB Output is correct
91 Correct 10 ms 1292 KB Output is correct
92 Correct 8 ms 1272 KB Output is correct
93 Correct 9 ms 1244 KB Output is correct
94 Correct 6 ms 1268 KB Output is correct
95 Correct 9 ms 1272 KB Output is correct
96 Correct 12 ms 1912 KB Output is correct
97 Correct 14 ms 1904 KB Output is correct
98 Correct 14 ms 2040 KB Output is correct
99 Correct 13 ms 1900 KB Output is correct
100 Correct 15 ms 1888 KB Output is correct
101 Correct 4 ms 632 KB Output is correct
102 Correct 4 ms 760 KB Output is correct
103 Correct 13 ms 1860 KB Output is correct
104 Correct 4 ms 632 KB Output is correct
105 Correct 5 ms 632 KB Output is correct
106 Correct 6 ms 760 KB Output is correct
107 Correct 6 ms 632 KB Output is correct
108 Correct 4 ms 632 KB Output is correct
109 Correct 11 ms 1224 KB Output is correct
110 Correct 6 ms 1272 KB Output is correct
111 Correct 12 ms 1912 KB Output is correct
112 Correct 3 ms 632 KB Output is correct
113 Correct 4 ms 632 KB Output is correct
114 Correct 12 ms 1912 KB Output is correct
115 Correct 3 ms 616 KB Output is correct
116 Correct 0 ms 632 KB Output is correct
117 Correct 9 ms 1280 KB Output is correct
118 Correct 9 ms 1292 KB Output is correct
119 Correct 12 ms 1912 KB Output is correct
120 Correct 14 ms 1912 KB Output is correct
121 Correct 8 ms 1912 KB Output is correct
122 Correct 17 ms 1912 KB Output is correct
123 Correct 24 ms 1784 KB Output is correct
124 Correct 14 ms 1912 KB Output is correct
125 Correct 14 ms 1912 KB Output is correct
126 Correct 17 ms 1884 KB Output is correct
127 Correct 13 ms 1912 KB Output is correct
128 Correct 13 ms 1884 KB Output is correct