답안 #621123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
621123 2022-08-03T12:35:00 Z beaconmc Vision Program (IOI19_vision) C++14
100 / 100
67 ms 6480 KB
#include "vision.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef int ll;
using namespace std;
using namespace __gnu_pbds;

#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll h,w,k;

vector<int> hashh(vector<int> a){
	return {a[0]+a[1], a[1]-a[0]};
}

int unhashh(vector<int> a){
	vector<int> temp =  {(a[0]-a[1])/2, (a[0]+a[1])/2};

	return w*temp[0]+temp[1];
}

// vector<int> arr = {0,1,1};

// int add_and(vector<int> a){
// 	FOR(i,0,a.size()){
// 		a[i] = arr[a[i]];
// 	}
// 	FOR(i,1,a.size()){
// 		a[0] &= a[i];
// 	}
// 	arr.push_back(a[0]);
// 	return arr.size()-1;
// }
// int add_xor(vector<int> a){
// 	FOR(i,0,a.size()){
// 		a[i] = arr[a[i]];
// 	}

// 	FOR(i,1,a.size()){
// 		a[0] ^= a[i];
// 	}
// 	arr.push_back(a[0]);
// 	return arr.size()-1;
// }
// int add_or(vector<int> a){
// 	FOR(i,0,a.size()){
// 		a[i] = arr[a[i]];
// 	}
// 	FOR(i,1,a.size()){
// 		a[0] |= a[i];
// 	}
// 	arr.push_back(a[0]);
// 	return arr.size()-1;
// }
// int add_not(int a){
// 	if(arr[a]) arr.push_back(0);
// 	else arr.push_back(1);
// 	return arr.size()-1;
// }



void construct_network(int H, int W, int K) {
	h=H; w=W; k=K;

	set<ll> x;
	set<ll> y;
	unordered_map<ll, vector<ll>> xs;
	unordered_map<ll, vector<ll>> ys;
	unordered_map<ll, ll> xx;
	unordered_map<ll, ll> yy;


	vector<vector<ll>> stuff;
	FOR(i,0,h){
		FOR(j,0,w){
			stuff.push_back(hashh({i,j}));
		}
	}

	for (auto&i : stuff){
		x.insert(i[0]);
		y.insert(i[1]);
		xs[i[0]].push_back(unhashh(i));
		ys[i[1]].push_back(unhashh(i));
	}
	for (auto&i : xs){

		xx[i.first] = add_xor(i.second);
	}

	for (auto&i : ys){

		yy[i.first] = add_xor(i.second);
	}



	vector<int> fx, fy, sx, sy;

	for (auto&i : x){

		vector<int> fir,sec;
		for (auto&j : x){
			if (j == i) fir.push_back(xx[j]);
			else if (j == i-k || j == i+k) sec.push_back(xx[j]);
		}
		if (!(fir.size() && sec.size())){
			fx.push_back(add_xor({0,0}));
			continue;
		}

		fx.push_back(add_and({add_xor(fir),add_xor(sec)}));

	}
	for (auto&i : y){
		vector<int> fir,sec;
		for (auto&j : y){

			if (j == i) fir.push_back(yy[j]);
			else if (j < i-k || j > i+k) sec.push_back(yy[j]);
		}

		if (!(fir.size() && sec.size())){

			fy.push_back(add_xor({0,0}));
			continue;
		}

		fy.push_back(add_and({add_xor(fir),add_xor(sec)}));
	}


	for (auto&i : y){
		vector<int> fir,sec;
		for (auto&j : y){
			if (j == i) fir.push_back(yy[j]);
			else if (j == i-k || j == i+k) sec.push_back(yy[j]);
		}
		if (!(fir.size() && sec.size())){
			sy.push_back(add_xor({0,0}));
			continue;
		}
		sy.push_back(add_and({add_xor(fir),add_xor(sec)}));
	}

	for (auto&i : x){
		vector<int> fir,sec;
		for (auto&j : x){
			if (j == i) fir.push_back(xx[j]);
			else if (j < i-k || j > i+k) sec.push_back(xx[j]);
		}
		if (!(fir.size() && sec.size())){
			sx.push_back(add_xor({0,0}));
			continue;
		}
		sx.push_back(add_and({add_xor(fir),add_xor(sec)}));
	}


	ll a,b,c,d;
	a = add_or(fx);
	b = add_not(add_or(fy));
	c = add_or(sy);
	d = add_not(add_or(sx));


	ll aa = add_and({a,b});
	ll bb = add_and({c,d});

	add_or({aa,bb});

}

// int main(){
// 	construct_network(3,1,1);
// 	for (auto&i : arr) cout << i << " ";
// }


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 13 ms 1524 KB Output is correct
39 Correct 3 ms 468 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 8 ms 1132 KB Output is correct
42 Correct 4 ms 724 KB Output is correct
43 Correct 15 ms 1916 KB Output is correct
44 Correct 12 ms 1552 KB Output is correct
45 Correct 9 ms 1380 KB Output is correct
46 Correct 7 ms 1168 KB Output is correct
47 Correct 7 ms 1124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1220 KB Output is correct
2 Correct 5 ms 724 KB Output is correct
3 Correct 5 ms 680 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 10 ms 1144 KB Output is correct
6 Correct 8 ms 852 KB Output is correct
7 Correct 4 ms 664 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 10 ms 1236 KB Output is correct
10 Correct 9 ms 936 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
12 Correct 4 ms 680 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 10 ms 1128 KB Output is correct
16 Correct 7 ms 852 KB Output is correct
17 Correct 5 ms 724 KB Output is correct
18 Correct 5 ms 724 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 6 ms 980 KB Output is correct
4 Correct 5 ms 796 KB Output is correct
5 Correct 5 ms 684 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 12 ms 1468 KB Output is correct
9 Correct 9 ms 1224 KB Output is correct
10 Correct 8 ms 980 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
12 Correct 6 ms 852 KB Output is correct
13 Correct 10 ms 1120 KB Output is correct
14 Correct 6 ms 852 KB Output is correct
15 Correct 4 ms 596 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 11 ms 1192 KB Output is correct
18 Correct 5 ms 684 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 31 ms 3692 KB Output is correct
21 Correct 25 ms 2740 KB Output is correct
22 Correct 16 ms 2116 KB Output is correct
23 Correct 14 ms 1932 KB Output is correct
24 Correct 32 ms 3748 KB Output is correct
25 Correct 19 ms 2464 KB Output is correct
26 Correct 13 ms 1932 KB Output is correct
27 Correct 58 ms 6480 KB Output is correct
28 Correct 42 ms 5060 KB Output is correct
29 Correct 36 ms 4140 KB Output is correct
30 Correct 31 ms 3680 KB Output is correct
31 Correct 25 ms 3592 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 6448 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 6 ms 980 KB Output is correct
4 Correct 11 ms 1432 KB Output is correct
5 Correct 10 ms 1108 KB Output is correct
6 Correct 11 ms 1168 KB Output is correct
7 Correct 36 ms 3700 KB Output is correct
8 Correct 32 ms 3904 KB Output is correct
9 Correct 67 ms 6468 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 13 ms 1524 KB Output is correct
39 Correct 3 ms 468 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 8 ms 1132 KB Output is correct
42 Correct 4 ms 724 KB Output is correct
43 Correct 15 ms 1916 KB Output is correct
44 Correct 12 ms 1552 KB Output is correct
45 Correct 9 ms 1380 KB Output is correct
46 Correct 7 ms 1168 KB Output is correct
47 Correct 7 ms 1124 KB Output is correct
48 Correct 12 ms 1220 KB Output is correct
49 Correct 5 ms 724 KB Output is correct
50 Correct 5 ms 680 KB Output is correct
51 Correct 2 ms 428 KB Output is correct
52 Correct 10 ms 1144 KB Output is correct
53 Correct 8 ms 852 KB Output is correct
54 Correct 4 ms 664 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 10 ms 1236 KB Output is correct
57 Correct 9 ms 936 KB Output is correct
58 Correct 5 ms 724 KB Output is correct
59 Correct 4 ms 680 KB Output is correct
60 Correct 4 ms 468 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 10 ms 1128 KB Output is correct
63 Correct 7 ms 852 KB Output is correct
64 Correct 5 ms 724 KB Output is correct
65 Correct 5 ms 724 KB Output is correct
66 Correct 3 ms 468 KB Output is correct
67 Correct 2 ms 468 KB Output is correct
68 Correct 0 ms 296 KB Output is correct
69 Correct 1 ms 296 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 6 ms 980 KB Output is correct
73 Correct 5 ms 796 KB Output is correct
74 Correct 5 ms 684 KB Output is correct
75 Correct 4 ms 724 KB Output is correct
76 Correct 2 ms 596 KB Output is correct
77 Correct 12 ms 1468 KB Output is correct
78 Correct 9 ms 1224 KB Output is correct
79 Correct 8 ms 980 KB Output is correct
80 Correct 5 ms 852 KB Output is correct
81 Correct 6 ms 852 KB Output is correct
82 Correct 10 ms 1120 KB Output is correct
83 Correct 6 ms 852 KB Output is correct
84 Correct 4 ms 596 KB Output is correct
85 Correct 2 ms 468 KB Output is correct
86 Correct 11 ms 1192 KB Output is correct
87 Correct 5 ms 684 KB Output is correct
88 Correct 2 ms 468 KB Output is correct
89 Correct 31 ms 3692 KB Output is correct
90 Correct 25 ms 2740 KB Output is correct
91 Correct 16 ms 2116 KB Output is correct
92 Correct 14 ms 1932 KB Output is correct
93 Correct 32 ms 3748 KB Output is correct
94 Correct 19 ms 2464 KB Output is correct
95 Correct 13 ms 1932 KB Output is correct
96 Correct 58 ms 6480 KB Output is correct
97 Correct 42 ms 5060 KB Output is correct
98 Correct 36 ms 4140 KB Output is correct
99 Correct 31 ms 3680 KB Output is correct
100 Correct 25 ms 3592 KB Output is correct
101 Correct 1 ms 212 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 55 ms 6448 KB Output is correct
104 Correct 0 ms 212 KB Output is correct
105 Correct 6 ms 980 KB Output is correct
106 Correct 11 ms 1432 KB Output is correct
107 Correct 10 ms 1108 KB Output is correct
108 Correct 11 ms 1168 KB Output is correct
109 Correct 36 ms 3700 KB Output is correct
110 Correct 32 ms 3904 KB Output is correct
111 Correct 67 ms 6468 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 45 ms 5072 KB Output is correct
115 Correct 2 ms 468 KB Output is correct
116 Correct 11 ms 1204 KB Output is correct
117 Correct 15 ms 2068 KB Output is correct
118 Correct 27 ms 3252 KB Output is correct
119 Correct 32 ms 4064 KB Output is correct
120 Correct 36 ms 4044 KB Output is correct
121 Correct 33 ms 4068 KB Output is correct
122 Correct 32 ms 4068 KB Output is correct
123 Correct 56 ms 6464 KB Output is correct
124 Correct 42 ms 5076 KB Output is correct
125 Correct 37 ms 4028 KB Output is correct
126 Correct 32 ms 4060 KB Output is correct
127 Correct 26 ms 3708 KB Output is correct
128 Correct 25 ms 3528 KB Output is correct