답안 #826974

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826974 2023-08-16T07:40:27 Z Amylopectin Vision Program (IOI19_vision) C++14
100 / 100
11 ms 1644 KB
#include "vision.h"
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;
const int mxn = 2e3 + 10;
int n,m,ta[2][mxn] = {},z[2] = {},ru,nu[2][3][mxn] = {},l[2] = {},se[mxn] = {}
,fta[2][2][mxn] = {},fnu[mxn] = {};
vector<int> fa,fa2[mxn] = {};
int fii(int cl,int cr,int no,int ot,int v,int be,int dep)
{
	if(cl == cr)
	{
		// se[no] = fta[ot][v][cl];
		return 0;
	}
	int mid = (cl+cr) / 2,nbe,nf,nfb,sle;
	add_not(fta[ot][v][mid]);
	nf = ru;
	ru ++;
	add_and({nf,be});
	nfb = ru;
	ru ++;
	add_and({fta[ot][v][mid],be});
	sle = ru;
	ru ++;
	fa2[dep].push_back(nfb);
	fii(cl,mid,no*2,ot,v,sle,dep-1);
	fii(mid+1,cr,no*2+1,ot,v,nfb,dep-1);
	return 0;
}
void construct_network(int H, int W, int K) 
{
	int i,j,cn,cm,fn,fm,k,lava,cxr,nm,ncxr,be,t1,t2,t3,t4;
	n = H;
	m = W;
	lava = K;
	ru = n*m;
	l[0] = n;
	l[1] = m;
	nm = 256;
	add_xor({0,0});
	z[0] = ru;
	ru ++;
	add_not(z[0]);
	z[1] = ru;
	ru++;
	for(i=0; i<n; i++)
	{
		fa.clear();
		for(j=0; j<m; j++)
		{
			fa.push_back(i*m + j);
		}
		add_or(fa);
		ta[0][i] = ru;
		ru ++;
	}
	for(i=n; i<nm; i++)
	{
		ta[0][i] = z[0];
	}
	for(j=0; j<m; j++)
	{
		fa.clear();
		for(i=0; i<n; i++)
		{
			fa.push_back(i*m + j);
		}
		add_or(fa);
		ta[1][j] = ru;
		ru ++;
	}
	for(i=m; i<nm; i++)
	{
		ta[1][i] = z[0];
	}
	// printf("sec1\n");
	for(i=0; i<2; i++)
	{
		for(j=0; j<2; j++)
		{
			if(j == 0)
			{
				fta[i][j][0] = ta[i][0];
				for(k=1; k<nm; k++)
				{
					add_or({fta[i][j][k-1],ta[i][k]});
					fta[i][j][k] = ru;
					ru ++;
				}
			}
			else 
			{
				cxr = ta[i][0];
				fta[i][j][0] = z[0];
				for(k=1; k<nm; k++)
				{
					add_xor({cxr,ta[i][k]});
					cxr = ru;
					ru ++;
					add_not(cxr);
					ncxr = ru;
					ru ++;
					add_and({fta[i][0][k],ncxr});
					fta[i][j][k] = ru;
					ru ++;
				}
			}
			add_not(z[0]);
			add_not(z[0]);
			add_not(z[0]);
			add_not(z[0]);
			add_not(z[0]);
			ru += 5;
			for(k=0; k<8; k++)
			{
				fa2[k].clear();
			}
			fii(0,nm-1,1,i,j,z[1],7);
			for(k=7; k>=0; k--)
			{
				add_or(fa2[k]);
				nu[i][j][k] = ru;
				ru ++;
			}
		}
		//minus
		be = z[0];
		for(j=0; j<8; j++)
		{
			add_xor({be,nu[i][0][j],nu[i][1][j]});
			nu[i][2][j] = ru;
			ru ++;
			add_and({nu[i][0][j],be});
			t1 = ru;
			ru ++;
			add_or({nu[i][0][j],be});
			t2 = ru;
			ru ++;
			add_not(nu[i][1][j]);
			t3 = ru;
			ru ++;
			add_and({t3,t2});
			t4 = ru;
			ru ++;
			add_or({t4,t1});
			be = ru;
			ru ++;
		}

		fa.clear();
		for(j=0; j<nm; j++)
		{
			fa.push_back(ta[i][j]);
		}
		add_xor(fa);
		cxr = ru;
		ru ++;
		add_not(cxr);
		ncxr = ru;
		ru++;
		for(j=0; j<8; j++)
		{
			add_and({ncxr,nu[i][2][j]});
			nu[i][2][j] = ru;
			ru++;
		}
	}
	//add
	be = z[0];
		for(j=0; j<8; j++)
		{
			add_xor({be,nu[0][2][j],nu[1][2][j]});
			fnu[j] = ru;
			ru ++;
			add_or({nu[0][2][j],be});
			t1 = ru;
			ru ++;
			add_or({nu[1][2][j],be});
			t2 = ru;
			ru ++;
			add_or({nu[0][2][j],nu[1][2][j]});
			t3 = ru;
			ru ++;
			add_and({t1,t2,t3});
			be = ru;
			ru ++;
		}
	fnu[8] = be;
	fa.clear();
	for(i=0; i<9; i++)
	{
		if((1<<i) & lava)
		{
			add_xor({z[1],fnu[i]});
		}
		else 
		{
			add_xor({z[0],fnu[i]});
		}
		fa.push_back(ru);
		ru ++;
	}
	add_or(fa);
	add_not(ru);
	ru += 2;
	return ;
	// std::vector<int> Ns;
	// Ns = {0, 1};
	// int a = add_and(Ns);
	// Ns = {0, a};
	// int b = add_or(Ns);
	// Ns = {0, 1, b};
	// int c = add_xor(Ns);
	// add_not(c);
}

Compilation message

vision.cpp: In function 'int fii(int, int, int, int, int, int, int)':
vision.cpp:17:24: warning: unused variable 'nbe' [-Wunused-variable]
   17 |  int mid = (cl+cr) / 2,nbe,nf,nfb,sle;
      |                        ^~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:34:10: warning: unused variable 'cn' [-Wunused-variable]
   34 |  int i,j,cn,cm,fn,fm,k,lava,cxr,nm,ncxr,be,t1,t2,t3,t4;
      |          ^~
vision.cpp:34:13: warning: unused variable 'cm' [-Wunused-variable]
   34 |  int i,j,cn,cm,fn,fm,k,lava,cxr,nm,ncxr,be,t1,t2,t3,t4;
      |             ^~
vision.cpp:34:16: warning: unused variable 'fn' [-Wunused-variable]
   34 |  int i,j,cn,cm,fn,fm,k,lava,cxr,nm,ncxr,be,t1,t2,t3,t4;
      |                ^~
vision.cpp:34:19: warning: unused variable 'fm' [-Wunused-variable]
   34 |  int i,j,cn,cm,fn,fm,k,lava,cxr,nm,ncxr,be,t1,t2,t3,t4;
      |                   ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 2 ms 784 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 2 ms 784 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 2 ms 724 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 2 ms 724 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 3 ms 724 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 2 ms 784 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 2 ms 724 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 2 ms 724 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 3 ms 724 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 3 ms 848 KB Output is correct
29 Correct 2 ms 724 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 724 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
34 Correct 3 ms 724 KB Output is correct
35 Correct 2 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 2 ms 784 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 2 ms 724 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 2 ms 724 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 3 ms 724 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 3 ms 848 KB Output is correct
29 Correct 2 ms 724 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 724 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
34 Correct 3 ms 724 KB Output is correct
35 Correct 2 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 4 ms 1084 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 2 ms 724 KB Output is correct
41 Correct 3 ms 848 KB Output is correct
42 Correct 3 ms 848 KB Output is correct
43 Correct 6 ms 980 KB Output is correct
44 Correct 4 ms 1092 KB Output is correct
45 Correct 4 ms 1076 KB Output is correct
46 Correct 4 ms 980 KB Output is correct
47 Correct 5 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 812 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 812 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 2 ms 824 KB Output is correct
7 Correct 2 ms 848 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 848 KB Output is correct
10 Correct 2 ms 848 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 848 KB Output is correct
13 Correct 2 ms 848 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 780 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 848 KB Output is correct
18 Correct 2 ms 848 KB Output is correct
19 Correct 2 ms 816 KB Output is correct
20 Correct 2 ms 848 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 756 KB Output is correct
3 Correct 3 ms 848 KB Output is correct
4 Correct 3 ms 848 KB Output is correct
5 Correct 3 ms 848 KB Output is correct
6 Correct 4 ms 848 KB Output is correct
7 Correct 3 ms 848 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 3 ms 848 KB Output is correct
10 Correct 3 ms 848 KB Output is correct
11 Correct 4 ms 844 KB Output is correct
12 Correct 3 ms 848 KB Output is correct
13 Correct 2 ms 800 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 5 ms 1232 KB Output is correct
21 Correct 6 ms 1232 KB Output is correct
22 Correct 7 ms 1104 KB Output is correct
23 Correct 6 ms 1232 KB Output is correct
24 Correct 6 ms 1232 KB Output is correct
25 Correct 5 ms 1232 KB Output is correct
26 Correct 5 ms 1232 KB Output is correct
27 Correct 8 ms 1548 KB Output is correct
28 Correct 8 ms 1552 KB Output is correct
29 Correct 8 ms 1616 KB Output is correct
30 Correct 9 ms 1616 KB Output is correct
31 Correct 8 ms 1544 KB Output is correct
32 Correct 2 ms 724 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1616 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 3 ms 848 KB Output is correct
4 Correct 3 ms 848 KB Output is correct
5 Correct 4 ms 892 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 5 ms 1232 KB Output is correct
8 Correct 6 ms 1208 KB Output is correct
9 Correct 11 ms 1620 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 2 ms 784 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 2 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 2 ms 724 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 2 ms 724 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 3 ms 724 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 3 ms 848 KB Output is correct
29 Correct 2 ms 724 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 724 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
34 Correct 3 ms 724 KB Output is correct
35 Correct 2 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 4 ms 1084 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 2 ms 724 KB Output is correct
41 Correct 3 ms 848 KB Output is correct
42 Correct 3 ms 848 KB Output is correct
43 Correct 6 ms 980 KB Output is correct
44 Correct 4 ms 1092 KB Output is correct
45 Correct 4 ms 1076 KB Output is correct
46 Correct 4 ms 980 KB Output is correct
47 Correct 5 ms 1044 KB Output is correct
48 Correct 2 ms 724 KB Output is correct
49 Correct 2 ms 812 KB Output is correct
50 Correct 2 ms 724 KB Output is correct
51 Correct 2 ms 812 KB Output is correct
52 Correct 2 ms 724 KB Output is correct
53 Correct 2 ms 824 KB Output is correct
54 Correct 2 ms 848 KB Output is correct
55 Correct 2 ms 724 KB Output is correct
56 Correct 2 ms 848 KB Output is correct
57 Correct 2 ms 848 KB Output is correct
58 Correct 2 ms 724 KB Output is correct
59 Correct 2 ms 848 KB Output is correct
60 Correct 2 ms 848 KB Output is correct
61 Correct 2 ms 724 KB Output is correct
62 Correct 2 ms 780 KB Output is correct
63 Correct 2 ms 724 KB Output is correct
64 Correct 2 ms 848 KB Output is correct
65 Correct 2 ms 848 KB Output is correct
66 Correct 2 ms 816 KB Output is correct
67 Correct 2 ms 848 KB Output is correct
68 Correct 2 ms 724 KB Output is correct
69 Correct 2 ms 724 KB Output is correct
70 Correct 2 ms 724 KB Output is correct
71 Correct 2 ms 756 KB Output is correct
72 Correct 3 ms 848 KB Output is correct
73 Correct 3 ms 848 KB Output is correct
74 Correct 3 ms 848 KB Output is correct
75 Correct 4 ms 848 KB Output is correct
76 Correct 3 ms 848 KB Output is correct
77 Correct 3 ms 848 KB Output is correct
78 Correct 3 ms 848 KB Output is correct
79 Correct 3 ms 848 KB Output is correct
80 Correct 4 ms 844 KB Output is correct
81 Correct 3 ms 848 KB Output is correct
82 Correct 2 ms 800 KB Output is correct
83 Correct 2 ms 724 KB Output is correct
84 Correct 2 ms 724 KB Output is correct
85 Correct 2 ms 724 KB Output is correct
86 Correct 2 ms 724 KB Output is correct
87 Correct 2 ms 724 KB Output is correct
88 Correct 2 ms 724 KB Output is correct
89 Correct 5 ms 1232 KB Output is correct
90 Correct 6 ms 1232 KB Output is correct
91 Correct 7 ms 1104 KB Output is correct
92 Correct 6 ms 1232 KB Output is correct
93 Correct 6 ms 1232 KB Output is correct
94 Correct 5 ms 1232 KB Output is correct
95 Correct 5 ms 1232 KB Output is correct
96 Correct 8 ms 1548 KB Output is correct
97 Correct 8 ms 1552 KB Output is correct
98 Correct 8 ms 1616 KB Output is correct
99 Correct 9 ms 1616 KB Output is correct
100 Correct 8 ms 1544 KB Output is correct
101 Correct 2 ms 724 KB Output is correct
102 Correct 2 ms 724 KB Output is correct
103 Correct 8 ms 1616 KB Output is correct
104 Correct 2 ms 724 KB Output is correct
105 Correct 3 ms 848 KB Output is correct
106 Correct 3 ms 848 KB Output is correct
107 Correct 4 ms 892 KB Output is correct
108 Correct 2 ms 724 KB Output is correct
109 Correct 5 ms 1232 KB Output is correct
110 Correct 6 ms 1208 KB Output is correct
111 Correct 11 ms 1620 KB Output is correct
112 Correct 2 ms 724 KB Output is correct
113 Correct 2 ms 740 KB Output is correct
114 Correct 10 ms 1628 KB Output is correct
115 Correct 3 ms 740 KB Output is correct
116 Correct 2 ms 800 KB Output is correct
117 Correct 6 ms 1232 KB Output is correct
118 Correct 6 ms 1120 KB Output is correct
119 Correct 10 ms 1616 KB Output is correct
120 Correct 9 ms 1616 KB Output is correct
121 Correct 11 ms 1612 KB Output is correct
122 Correct 8 ms 1616 KB Output is correct
123 Correct 9 ms 1632 KB Output is correct
124 Correct 9 ms 1616 KB Output is correct
125 Correct 9 ms 1640 KB Output is correct
126 Correct 8 ms 1616 KB Output is correct
127 Correct 8 ms 1636 KB Output is correct
128 Correct 9 ms 1644 KB Output is correct