답안 #430000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
430000 2021-06-16T10:55:48 Z Jasiekstrz Vision Program (IOI19_vision) C++17
100 / 100
31 ms 2044 KB
#include<bits/stdc++.h>
#include "vision.h"
using namespace std;
const int X=200;
int h,w;
vector<int> primes;
bool composite[X+10];
int row[X+10]; // id of rows xor
int col[X+10]; // id of columns xor
vector<int> row_p[2];
vector<int> col_p[2];
int row_e[X+10];
int col_e[X+10];
int co(int x,int y)
{
	return (x-1)*w+y-1;
}
void construct_network(int H,int W,int K)
{
	vector<int> tmp;
	h=H;w=W;
	int it=h*w;
	int n=max(h,w);
	for(int i=2;i<=n;i++)
	{
		if(composite[i])
			continue;
		for(int j=i;j<=n;j*=i)
			primes.push_back(j);
		for(int j=2*i;j<=n;j+=i)
			composite[j]=true;
	}
	sort(primes.begin(),primes.end());

	// rows
	for(int i=1;i<=h;i++)
	{
		row[i]=it++;
		tmp.clear();
		for(int j=1;j<=w;j++)
			tmp.push_back(co(i,j));
		add_xor(tmp);
	}

	// columns
	for(int j=1;j<=w;j++)
	{
		col[j]=it++;
		tmp.clear();
		for(int i=1;i<=h;i++)
			tmp.push_back(co(i,j));
		add_xor(tmp);
	}

	// rows divisors
	for(auto p:primes)
	{
		if(p>h)
			break;
		vector<int> modt(p);
		for(int i=1;i<=p;i++)
		{
			if(i+p>h)
				modt[i-1]=row[i];
			else
			{
				modt[i-1]=it++;
				tmp.clear();
				for(int j=i;j<=h;j+=p)
					tmp.push_back(row[j]);
				add_xor(tmp);
			}
		}
		row_p[0].push_back(it++);
		add_or(modt);
		row_p[1].push_back(it++);
		add_not(row_p[0].back());
		//cerr<<"row_p "<<p<<" {"<<row_p[1].back()<<","<<row_p[0].back()<<"}\n";
	}

	// columns divisors
	for(auto p:primes)
	{
		if(p>w)
			break;
		vector<int> modt(p);
		for(int i=1;i<=p;i++)
		{
			if(i+p>w)
				modt[i-1]=col[i];
			else
			{
				modt[i-1]=it++;
				tmp.clear();
				for(int j=i;j<=w;j+=p)
					tmp.push_back(col[j]);
				add_xor(tmp);
			}
		}
		col_p[0].push_back(it++);
		add_or(modt);
		col_p[1].push_back(it++);
		add_not(col_p[0].back());
		//cerr<<"col_p "<<p<<" {"<<col_p[1].back()<<","<<col_p[0].back()<<"}\n";
	}

	// rows equal
	if(h==1)
	{
		row_e[0]=it++;
		add_not(row[1]);
	}
	else
	{
		for(int i=0;i<h;i++)
		{
			row_e[i]=it++;
			tmp.clear();
			for(size_t j=0;j<row_p[1].size();j++)
				tmp.push_back(row_p[i%primes[j]==0][j]);
			add_and(tmp);
			//cerr<<"row_e "<<i<<" "<<row_e[i]<<"\n";
		}
	}

	// columns equal
	if(w==1)
	{
		col_e[0]=it++;
		add_not(col[1]);
	}
	else
	{
		for(int i=0;i<w;i++)
		{
			col_e[i]=it++;
			tmp.clear();
			for(size_t j=0;j<col_p[1].size();j++)
				tmp.push_back(col_p[i%primes[j]==0][j]);
			add_and(tmp);
			//cerr<<"col_e "<<i<<" "<<col_e[i]<<"\n";
		}
	}

	// answer
	vector<int> ans;
	for(int r=0;r<=min(K,h-1);r++)
	{
		int c=K-r;
		if(c>w-1)
			continue;
		ans.push_back(it++);
		tmp={row_e[r],col_e[c]};
		add_and(tmp);
	}
	add_or(ans);
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 276 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 276 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 296 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 276 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 296 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 7 ms 716 KB Output is correct
39 Correct 2 ms 460 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 6 ms 460 KB Output is correct
42 Correct 3 ms 460 KB Output is correct
43 Correct 6 ms 716 KB Output is correct
44 Correct 6 ms 752 KB Output is correct
45 Correct 9 ms 716 KB Output is correct
46 Correct 6 ms 716 KB Output is correct
47 Correct 8 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 716 KB Output is correct
2 Correct 5 ms 656 KB Output is correct
3 Correct 5 ms 716 KB Output is correct
4 Correct 7 ms 716 KB Output is correct
5 Correct 6 ms 716 KB Output is correct
6 Correct 5 ms 716 KB Output is correct
7 Correct 5 ms 716 KB Output is correct
8 Correct 5 ms 716 KB Output is correct
9 Correct 5 ms 716 KB Output is correct
10 Correct 5 ms 716 KB Output is correct
11 Correct 5 ms 704 KB Output is correct
12 Correct 7 ms 716 KB Output is correct
13 Correct 8 ms 616 KB Output is correct
14 Correct 5 ms 716 KB Output is correct
15 Correct 5 ms 716 KB Output is correct
16 Correct 5 ms 716 KB Output is correct
17 Correct 7 ms 716 KB Output is correct
18 Correct 7 ms 716 KB Output is correct
19 Correct 5 ms 716 KB Output is correct
20 Correct 7 ms 716 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 436 KB Output is correct
5 Correct 4 ms 460 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 7 ms 716 KB Output is correct
9 Correct 6 ms 700 KB Output is correct
10 Correct 5 ms 744 KB Output is correct
11 Correct 5 ms 680 KB Output is correct
12 Correct 7 ms 716 KB Output is correct
13 Correct 6 ms 716 KB Output is correct
14 Correct 7 ms 716 KB Output is correct
15 Correct 5 ms 716 KB Output is correct
16 Correct 7 ms 716 KB Output is correct
17 Correct 6 ms 716 KB Output is correct
18 Correct 6 ms 716 KB Output is correct
19 Correct 7 ms 664 KB Output is correct
20 Correct 10 ms 1224 KB Output is correct
21 Correct 15 ms 1236 KB Output is correct
22 Correct 16 ms 1284 KB Output is correct
23 Correct 14 ms 1188 KB Output is correct
24 Correct 16 ms 1180 KB Output is correct
25 Correct 14 ms 1300 KB Output is correct
26 Correct 11 ms 1224 KB Output is correct
27 Correct 26 ms 1860 KB Output is correct
28 Correct 18 ms 1992 KB Output is correct
29 Correct 25 ms 1992 KB Output is correct
30 Correct 19 ms 1976 KB Output is correct
31 Correct 20 ms 1992 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1892 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 6 ms 716 KB Output is correct
5 Correct 5 ms 716 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 10 ms 1224 KB Output is correct
8 Correct 11 ms 1212 KB Output is correct
9 Correct 21 ms 1984 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 276 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 296 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 7 ms 716 KB Output is correct
39 Correct 2 ms 460 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 6 ms 460 KB Output is correct
42 Correct 3 ms 460 KB Output is correct
43 Correct 6 ms 716 KB Output is correct
44 Correct 6 ms 752 KB Output is correct
45 Correct 9 ms 716 KB Output is correct
46 Correct 6 ms 716 KB Output is correct
47 Correct 8 ms 716 KB Output is correct
48 Correct 6 ms 716 KB Output is correct
49 Correct 5 ms 656 KB Output is correct
50 Correct 5 ms 716 KB Output is correct
51 Correct 7 ms 716 KB Output is correct
52 Correct 6 ms 716 KB Output is correct
53 Correct 5 ms 716 KB Output is correct
54 Correct 5 ms 716 KB Output is correct
55 Correct 5 ms 716 KB Output is correct
56 Correct 5 ms 716 KB Output is correct
57 Correct 5 ms 716 KB Output is correct
58 Correct 5 ms 704 KB Output is correct
59 Correct 7 ms 716 KB Output is correct
60 Correct 8 ms 616 KB Output is correct
61 Correct 5 ms 716 KB Output is correct
62 Correct 5 ms 716 KB Output is correct
63 Correct 5 ms 716 KB Output is correct
64 Correct 7 ms 716 KB Output is correct
65 Correct 7 ms 716 KB Output is correct
66 Correct 5 ms 716 KB Output is correct
67 Correct 7 ms 716 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 3 ms 460 KB Output is correct
73 Correct 3 ms 436 KB Output is correct
74 Correct 4 ms 460 KB Output is correct
75 Correct 3 ms 492 KB Output is correct
76 Correct 4 ms 460 KB Output is correct
77 Correct 7 ms 716 KB Output is correct
78 Correct 6 ms 700 KB Output is correct
79 Correct 5 ms 744 KB Output is correct
80 Correct 5 ms 680 KB Output is correct
81 Correct 7 ms 716 KB Output is correct
82 Correct 6 ms 716 KB Output is correct
83 Correct 7 ms 716 KB Output is correct
84 Correct 5 ms 716 KB Output is correct
85 Correct 7 ms 716 KB Output is correct
86 Correct 6 ms 716 KB Output is correct
87 Correct 6 ms 716 KB Output is correct
88 Correct 7 ms 664 KB Output is correct
89 Correct 10 ms 1224 KB Output is correct
90 Correct 15 ms 1236 KB Output is correct
91 Correct 16 ms 1284 KB Output is correct
92 Correct 14 ms 1188 KB Output is correct
93 Correct 16 ms 1180 KB Output is correct
94 Correct 14 ms 1300 KB Output is correct
95 Correct 11 ms 1224 KB Output is correct
96 Correct 26 ms 1860 KB Output is correct
97 Correct 18 ms 1992 KB Output is correct
98 Correct 25 ms 1992 KB Output is correct
99 Correct 19 ms 1976 KB Output is correct
100 Correct 20 ms 1992 KB Output is correct
101 Correct 1 ms 204 KB Output is correct
102 Correct 1 ms 204 KB Output is correct
103 Correct 23 ms 1892 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 3 ms 460 KB Output is correct
106 Correct 6 ms 716 KB Output is correct
107 Correct 5 ms 716 KB Output is correct
108 Correct 6 ms 716 KB Output is correct
109 Correct 10 ms 1224 KB Output is correct
110 Correct 11 ms 1212 KB Output is correct
111 Correct 21 ms 1984 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 31 ms 1992 KB Output is correct
115 Correct 5 ms 716 KB Output is correct
116 Correct 7 ms 716 KB Output is correct
117 Correct 17 ms 1192 KB Output is correct
118 Correct 14 ms 1224 KB Output is correct
119 Correct 23 ms 1940 KB Output is correct
120 Correct 18 ms 2004 KB Output is correct
121 Correct 24 ms 1992 KB Output is correct
122 Correct 29 ms 1928 KB Output is correct
123 Correct 18 ms 1984 KB Output is correct
124 Correct 18 ms 1960 KB Output is correct
125 Correct 24 ms 2044 KB Output is correct
126 Correct 18 ms 2012 KB Output is correct
127 Correct 21 ms 1948 KB Output is correct
128 Correct 23 ms 1896 KB Output is correct