답안 #423544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
423544 2021-06-11T09:14:53 Z errorgorn Vision Program (IOI19_vision) C++17
100 / 100
44 ms 3248 KB
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include "vision.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << ": " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int h,w,k;
int IDX;

int TRUE_IDX; //creating a true

int row[205]; //store entire row
int col[205]; //store entire col

int rowb[10][2]; //(is there,not there)
int colb[10][2];

int rdist[205];
int cdist[205];

void construct_network(int H, int W, int K) {
	h=H,w=W,k=K;
	IDX=h*w;
	
	vector<int> vtrue;
	rep(x,0,h*w) vtrue.pub(x);
	add_or(vtrue);
	TRUE_IDX=IDX++;
	
	rep(x,0,h){
		vector<int> v;
		rep(y,0,w) v.pub(x*w+y);
		add_or(v);
		row[x]=IDX++;
	}
	
	rep(y,0,w){
		vector<int> v;
		rep(x,0,h) v.pub(x*w+y);
		add_or(v);
		col[y]=IDX++;
	}
	
	for (int p2=1;p2<=256;p2<<=1){
		vector<int> res;
		rep(x,0,h){
			vector<int> blacks;
			
			rep(y,x+1,h) if ((y-x)/p2%2==1){
				blacks.pub(row[y]);
			}
			
			if (blacks.empty()) break;
			
			add_or(blacks);
			add_and({row[x],IDX});
			res.pub(IDX+1);
			IDX+=2;
		}
		
		if (res.empty()) break;
		
		add_or(res);
		rowb[__builtin_ctz(p2)][0]=IDX;
		
		add_not(IDX);
		rowb[__builtin_ctz(p2)][1]=IDX+1;
		
		IDX+=2;
	}
	
	for (int p2=1;p2<=256;p2<<=1){
		vector<int> res;
		rep(x,0,w){
			vector<int> blacks;
			
			rep(y,x+1,w) if ((y-x)/p2%2==1){
				blacks.pub(col[y]);
			}
			
			if (blacks.empty()) break;
			
			add_or(blacks);
			add_and({col[x],IDX});
			res.pub(IDX+1);
			IDX+=2;
		}
		
		if (res.empty()) break;
		
		add_or(res);
		colb[__builtin_ctz(p2)][0]=IDX;
		
		add_not(IDX);
		colb[__builtin_ctz(p2)][1]=IDX+1;
		
		IDX+=2;
	}
	
	rep(x,0,h){
		vector<int> v;
		for (int p2=1;p2<h;p2<<=1){
			if (x&p2) v.pub(rowb[__builtin_ctz(p2)][0]);
			else v.pub(rowb[__builtin_ctz(p2)][1]);
		}
		
		if (v.empty()){
			rdist[x]=TRUE_IDX;
		}
		else{
			add_and(v);
			rdist[x]=IDX++;
		}
	}
	
	rep(x,0,w){
		vector<int> v;
		for (int p2=1;p2<w;p2<<=1){
			if (x&p2) v.pub(colb[__builtin_ctz(p2)][0]);
			else v.pub(colb[__builtin_ctz(p2)][1]);
		}
		
		if (v.empty()){
			cdist[x]=TRUE_IDX;
		}
		else{
			add_and(v);
			cdist[x]=IDX++;
		}
	}
	
	vector<int> v;
	rep(x,0,h){
		int y=k-x;
		if (0<=y && y<w){
			//cout<<"debug: "<<x<<" "<<y<<endl;
			add_and({rdist[x],cdist[y]});
			v.pub(IDX);
			IDX++;
		}
	}
	
	add_or(v);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 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 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 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 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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 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 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 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 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 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 300 KB Output is correct
27 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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 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 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 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 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 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 300 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 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 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 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 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 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 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 300 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 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 9 ms 1100 KB Output is correct
39 Correct 3 ms 424 KB Output is correct
40 Correct 3 ms 460 KB Output is correct
41 Correct 6 ms 716 KB Output is correct
42 Correct 6 ms 716 KB Output is correct
43 Correct 10 ms 1100 KB Output is correct
44 Correct 14 ms 1092 KB Output is correct
45 Correct 9 ms 1060 KB Output is correct
46 Correct 10 ms 1020 KB Output is correct
47 Correct 10 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1064 KB Output is correct
2 Correct 18 ms 992 KB Output is correct
3 Correct 16 ms 948 KB Output is correct
4 Correct 10 ms 972 KB Output is correct
5 Correct 10 ms 972 KB Output is correct
6 Correct 10 ms 972 KB Output is correct
7 Correct 10 ms 984 KB Output is correct
8 Correct 10 ms 972 KB Output is correct
9 Correct 11 ms 972 KB Output is correct
10 Correct 10 ms 1012 KB Output is correct
11 Correct 11 ms 972 KB Output is correct
12 Correct 14 ms 972 KB Output is correct
13 Correct 13 ms 1024 KB Output is correct
14 Correct 15 ms 1044 KB Output is correct
15 Correct 11 ms 1040 KB Output is correct
16 Correct 11 ms 972 KB Output is correct
17 Correct 13 ms 1000 KB Output is correct
18 Correct 11 ms 1064 KB Output is correct
19 Correct 10 ms 972 KB Output is correct
20 Correct 12 ms 972 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 296 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 5 ms 564 KB Output is correct
4 Correct 5 ms 580 KB Output is correct
5 Correct 4 ms 588 KB Output is correct
6 Correct 5 ms 532 KB Output is correct
7 Correct 5 ms 536 KB Output is correct
8 Correct 8 ms 972 KB Output is correct
9 Correct 8 ms 972 KB Output is correct
10 Correct 8 ms 972 KB Output is correct
11 Correct 8 ms 972 KB Output is correct
12 Correct 8 ms 972 KB Output is correct
13 Correct 10 ms 972 KB Output is correct
14 Correct 11 ms 972 KB Output is correct
15 Correct 10 ms 1060 KB Output is correct
16 Correct 10 ms 1016 KB Output is correct
17 Correct 13 ms 1052 KB Output is correct
18 Correct 13 ms 936 KB Output is correct
19 Correct 10 ms 1048 KB Output is correct
20 Correct 21 ms 1988 KB Output is correct
21 Correct 20 ms 1980 KB Output is correct
22 Correct 20 ms 1956 KB Output is correct
23 Correct 20 ms 1932 KB Output is correct
24 Correct 20 ms 2024 KB Output is correct
25 Correct 20 ms 1916 KB Output is correct
26 Correct 26 ms 1920 KB Output is correct
27 Correct 34 ms 3196 KB Output is correct
28 Correct 34 ms 3200 KB Output is correct
29 Correct 37 ms 3204 KB Output is correct
30 Correct 38 ms 3156 KB Output is correct
31 Correct 36 ms 3148 KB Output is correct
32 Correct 1 ms 300 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 3200 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 5 ms 588 KB Output is correct
4 Correct 10 ms 972 KB Output is correct
5 Correct 13 ms 980 KB Output is correct
6 Correct 10 ms 1020 KB Output is correct
7 Correct 25 ms 1932 KB Output is correct
8 Correct 20 ms 1904 KB Output is correct
9 Correct 34 ms 3168 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 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 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 304 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 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 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 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 300 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 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 9 ms 1100 KB Output is correct
39 Correct 3 ms 424 KB Output is correct
40 Correct 3 ms 460 KB Output is correct
41 Correct 6 ms 716 KB Output is correct
42 Correct 6 ms 716 KB Output is correct
43 Correct 10 ms 1100 KB Output is correct
44 Correct 14 ms 1092 KB Output is correct
45 Correct 9 ms 1060 KB Output is correct
46 Correct 10 ms 1020 KB Output is correct
47 Correct 10 ms 1100 KB Output is correct
48 Correct 11 ms 1064 KB Output is correct
49 Correct 18 ms 992 KB Output is correct
50 Correct 16 ms 948 KB Output is correct
51 Correct 10 ms 972 KB Output is correct
52 Correct 10 ms 972 KB Output is correct
53 Correct 10 ms 972 KB Output is correct
54 Correct 10 ms 984 KB Output is correct
55 Correct 10 ms 972 KB Output is correct
56 Correct 11 ms 972 KB Output is correct
57 Correct 10 ms 1012 KB Output is correct
58 Correct 11 ms 972 KB Output is correct
59 Correct 14 ms 972 KB Output is correct
60 Correct 13 ms 1024 KB Output is correct
61 Correct 15 ms 1044 KB Output is correct
62 Correct 11 ms 1040 KB Output is correct
63 Correct 11 ms 972 KB Output is correct
64 Correct 13 ms 1000 KB Output is correct
65 Correct 11 ms 1064 KB Output is correct
66 Correct 10 ms 972 KB Output is correct
67 Correct 12 ms 972 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 296 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 5 ms 564 KB Output is correct
73 Correct 5 ms 580 KB Output is correct
74 Correct 4 ms 588 KB Output is correct
75 Correct 5 ms 532 KB Output is correct
76 Correct 5 ms 536 KB Output is correct
77 Correct 8 ms 972 KB Output is correct
78 Correct 8 ms 972 KB Output is correct
79 Correct 8 ms 972 KB Output is correct
80 Correct 8 ms 972 KB Output is correct
81 Correct 8 ms 972 KB Output is correct
82 Correct 10 ms 972 KB Output is correct
83 Correct 11 ms 972 KB Output is correct
84 Correct 10 ms 1060 KB Output is correct
85 Correct 10 ms 1016 KB Output is correct
86 Correct 13 ms 1052 KB Output is correct
87 Correct 13 ms 936 KB Output is correct
88 Correct 10 ms 1048 KB Output is correct
89 Correct 21 ms 1988 KB Output is correct
90 Correct 20 ms 1980 KB Output is correct
91 Correct 20 ms 1956 KB Output is correct
92 Correct 20 ms 1932 KB Output is correct
93 Correct 20 ms 2024 KB Output is correct
94 Correct 20 ms 1916 KB Output is correct
95 Correct 26 ms 1920 KB Output is correct
96 Correct 34 ms 3196 KB Output is correct
97 Correct 34 ms 3200 KB Output is correct
98 Correct 37 ms 3204 KB Output is correct
99 Correct 38 ms 3156 KB Output is correct
100 Correct 36 ms 3148 KB Output is correct
101 Correct 1 ms 300 KB Output is correct
102 Correct 1 ms 204 KB Output is correct
103 Correct 44 ms 3200 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 5 ms 588 KB Output is correct
106 Correct 10 ms 972 KB Output is correct
107 Correct 13 ms 980 KB Output is correct
108 Correct 10 ms 1020 KB Output is correct
109 Correct 25 ms 1932 KB Output is correct
110 Correct 20 ms 1904 KB Output is correct
111 Correct 34 ms 3168 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 44 ms 3204 KB Output is correct
115 Correct 16 ms 972 KB Output is correct
116 Correct 10 ms 972 KB Output is correct
117 Correct 20 ms 1920 KB Output is correct
118 Correct 24 ms 1932 KB Output is correct
119 Correct 34 ms 3208 KB Output is correct
120 Correct 34 ms 3176 KB Output is correct
121 Correct 34 ms 3204 KB Output is correct
122 Correct 34 ms 3160 KB Output is correct
123 Correct 34 ms 3124 KB Output is correct
124 Correct 35 ms 3172 KB Output is correct
125 Correct 34 ms 3228 KB Output is correct
126 Correct 34 ms 3248 KB Output is correct
127 Correct 37 ms 3152 KB Output is correct
128 Correct 35 ms 3168 KB Output is correct