답안 #210334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210334 2020-03-17T05:16:49 Z Segtree Vision Program (IOI19_vision) C++14
100 / 100
79 ms 4472 KB
#include "vision.h"
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

void construct_network(int H, int W, int K) {
	vector<int> Ns;
	int T=H+W-1;
	for(int s=0;s<T;s++){
		Ns.clear();
		rep(i,H)rep(j,W)if(i+j==s)Ns.push_back(i*W+j);
		add_or(Ns);
	}
	for(int s=0;s<T;s++){
		Ns.clear();
		rep(i,H)rep(j,W)if(i-j+W-1==s)Ns.push_back(i*W+j);
		add_or(Ns);
	}
	int qid;
	for(int s=0;s+K<T;s++){
		Ns.clear();
		Ns={H*W+s,H*W+s+K};
		qid=add_and(Ns);
	}
	Ns.clear();
	for(int s=H*W+2*T;s<=qid;s++)Ns.push_back(s);
	int x_k=add_or(Ns);//xの距離がちょうどkなら1
	
	for(int s=0;s+K<T;s++){
		Ns.clear();
		Ns={H*W+T+s,H*W+T+s+K};
		qid=add_and(Ns);
	}
	Ns.clear();
	for(int s=x_k+1;s<=qid;s++)Ns.push_back(s);
	int y_k=add_or(Ns);//yの距離がちょうどkなら1
	
	if(K==T-1){
		Ns.clear();
		Ns.push_back(x_k);
		Ns.push_back(y_k);
		add_or(Ns);
		return;
	}
	
	for(int s=0;s+K<T;s++){
		Ns.clear();
		for(int i=0;i<s;i++)Ns.push_back(i+H*W);
		for(int i=s+K+1;i<T;i++)Ns.push_back(i+H*W);
		qid=add_or(Ns);
	}
	Ns.clear();
	for(int i=y_k+1;i<=qid;i++)Ns.push_back(i);
	int x_kinai=add_and(Ns);//xの距離がK以下なら0
	
	for(int s=0;s+K<T;s++){
		Ns.clear();
		for(int i=0;i<s;i++)Ns.push_back(i+T+H*W);
		for(int i=s+K+1;i<T;i++)Ns.push_back(i+T+H*W);
		qid=add_or(Ns);
	}
	Ns.clear();
	for(int i=x_kinai+1;i<=qid;i++)Ns.push_back(i);
	int y_kinai=add_and(Ns);//yの距離がK以下なら0
	
	int x_kinai_rev=add_not(x_kinai);
	int y_kinai_rev=add_not(y_kinai);
	Ns.clear();
	Ns.push_back(x_k);
	Ns.push_back(y_kinai_rev);
	int vl=add_and(Ns);
	Ns.clear();
	Ns.push_back(y_k);
	Ns.push_back(x_kinai_rev);
	int vr=add_and(Ns);
	Ns.clear();
	Ns.push_back(vl);
	Ns.push_back(vr);
	add_or(Ns);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:40:21: warning: 'qid' may be used uninitialized in this function [-Wmaybe-uninitialized]
  for(int s=H*W+2*T;s<=qid;s++)Ns.push_back(s);
                    ~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 248 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 248 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 256 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 248 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 256 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 256 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 256 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 248 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 256 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 256 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 256 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 16 ms 1016 KB Output is correct
39 Correct 6 ms 376 KB Output is correct
40 Correct 6 ms 396 KB Output is correct
41 Correct 12 ms 908 KB Output is correct
42 Correct 7 ms 376 KB Output is correct
43 Correct 21 ms 1404 KB Output is correct
44 Correct 15 ms 1016 KB Output is correct
45 Correct 13 ms 760 KB Output is correct
46 Correct 11 ms 504 KB Output is correct
47 Correct 12 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1016 KB Output is correct
2 Correct 7 ms 504 KB Output is correct
3 Correct 7 ms 504 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 13 ms 1016 KB Output is correct
6 Correct 9 ms 632 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 14 ms 1016 KB Output is correct
10 Correct 10 ms 760 KB Output is correct
11 Correct 8 ms 504 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 6 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 14 ms 1016 KB Output is correct
16 Correct 10 ms 760 KB Output is correct
17 Correct 7 ms 504 KB Output is correct
18 Correct 7 ms 504 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 10 ms 760 KB Output is correct
4 Correct 8 ms 504 KB Output is correct
5 Correct 7 ms 504 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 15 ms 1016 KB Output is correct
9 Correct 12 ms 760 KB Output is correct
10 Correct 9 ms 632 KB Output is correct
11 Correct 8 ms 504 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 13 ms 1016 KB Output is correct
14 Correct 9 ms 632 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 14 ms 1016 KB Output is correct
18 Correct 7 ms 504 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 39 ms 2552 KB Output is correct
21 Correct 29 ms 1528 KB Output is correct
22 Correct 22 ms 888 KB Output is correct
23 Correct 19 ms 760 KB Output is correct
24 Correct 39 ms 2552 KB Output is correct
25 Correct 25 ms 1272 KB Output is correct
26 Correct 20 ms 760 KB Output is correct
27 Correct 79 ms 4344 KB Output is correct
28 Correct 58 ms 2936 KB Output is correct
29 Correct 48 ms 2040 KB Output is correct
30 Correct 39 ms 1400 KB Output is correct
31 Correct 37 ms 1144 KB Output is correct
32 Correct 5 ms 256 KB Output is correct
33 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 4472 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 10 ms 760 KB Output is correct
4 Correct 15 ms 1016 KB Output is correct
5 Correct 14 ms 1016 KB Output is correct
6 Correct 14 ms 1016 KB Output is correct
7 Correct 40 ms 2552 KB Output is correct
8 Correct 39 ms 2552 KB Output is correct
9 Correct 73 ms 4344 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 248 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 256 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 256 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 256 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 16 ms 1016 KB Output is correct
39 Correct 6 ms 376 KB Output is correct
40 Correct 6 ms 396 KB Output is correct
41 Correct 12 ms 908 KB Output is correct
42 Correct 7 ms 376 KB Output is correct
43 Correct 21 ms 1404 KB Output is correct
44 Correct 15 ms 1016 KB Output is correct
45 Correct 13 ms 760 KB Output is correct
46 Correct 11 ms 504 KB Output is correct
47 Correct 12 ms 504 KB Output is correct
48 Correct 14 ms 1016 KB Output is correct
49 Correct 7 ms 504 KB Output is correct
50 Correct 7 ms 504 KB Output is correct
51 Correct 5 ms 376 KB Output is correct
52 Correct 13 ms 1016 KB Output is correct
53 Correct 9 ms 632 KB Output is correct
54 Correct 6 ms 376 KB Output is correct
55 Correct 5 ms 376 KB Output is correct
56 Correct 14 ms 1016 KB Output is correct
57 Correct 10 ms 760 KB Output is correct
58 Correct 8 ms 504 KB Output is correct
59 Correct 7 ms 504 KB Output is correct
60 Correct 6 ms 380 KB Output is correct
61 Correct 5 ms 376 KB Output is correct
62 Correct 14 ms 1016 KB Output is correct
63 Correct 10 ms 760 KB Output is correct
64 Correct 7 ms 504 KB Output is correct
65 Correct 7 ms 504 KB Output is correct
66 Correct 6 ms 376 KB Output is correct
67 Correct 5 ms 376 KB Output is correct
68 Correct 4 ms 256 KB Output is correct
69 Correct 5 ms 256 KB Output is correct
70 Correct 5 ms 376 KB Output is correct
71 Correct 5 ms 256 KB Output is correct
72 Correct 10 ms 760 KB Output is correct
73 Correct 8 ms 504 KB Output is correct
74 Correct 7 ms 504 KB Output is correct
75 Correct 7 ms 376 KB Output is correct
76 Correct 6 ms 376 KB Output is correct
77 Correct 15 ms 1016 KB Output is correct
78 Correct 12 ms 760 KB Output is correct
79 Correct 9 ms 632 KB Output is correct
80 Correct 8 ms 504 KB Output is correct
81 Correct 7 ms 376 KB Output is correct
82 Correct 13 ms 1016 KB Output is correct
83 Correct 9 ms 632 KB Output is correct
84 Correct 6 ms 376 KB Output is correct
85 Correct 5 ms 376 KB Output is correct
86 Correct 14 ms 1016 KB Output is correct
87 Correct 7 ms 504 KB Output is correct
88 Correct 5 ms 376 KB Output is correct
89 Correct 39 ms 2552 KB Output is correct
90 Correct 29 ms 1528 KB Output is correct
91 Correct 22 ms 888 KB Output is correct
92 Correct 19 ms 760 KB Output is correct
93 Correct 39 ms 2552 KB Output is correct
94 Correct 25 ms 1272 KB Output is correct
95 Correct 20 ms 760 KB Output is correct
96 Correct 79 ms 4344 KB Output is correct
97 Correct 58 ms 2936 KB Output is correct
98 Correct 48 ms 2040 KB Output is correct
99 Correct 39 ms 1400 KB Output is correct
100 Correct 37 ms 1144 KB Output is correct
101 Correct 5 ms 256 KB Output is correct
102 Correct 4 ms 256 KB Output is correct
103 Correct 75 ms 4472 KB Output is correct
104 Correct 5 ms 256 KB Output is correct
105 Correct 10 ms 760 KB Output is correct
106 Correct 15 ms 1016 KB Output is correct
107 Correct 14 ms 1016 KB Output is correct
108 Correct 14 ms 1016 KB Output is correct
109 Correct 40 ms 2552 KB Output is correct
110 Correct 39 ms 2552 KB Output is correct
111 Correct 73 ms 4344 KB Output is correct
112 Correct 5 ms 256 KB Output is correct
113 Correct 5 ms 376 KB Output is correct
114 Correct 57 ms 3052 KB Output is correct
115 Correct 5 ms 376 KB Output is correct
116 Correct 14 ms 1016 KB Output is correct
117 Correct 20 ms 760 KB Output is correct
118 Correct 32 ms 2040 KB Output is correct
119 Correct 48 ms 1912 KB Output is correct
120 Correct 47 ms 1912 KB Output is correct
121 Correct 48 ms 1912 KB Output is correct
122 Correct 48 ms 1912 KB Output is correct
123 Correct 74 ms 4344 KB Output is correct
124 Correct 59 ms 2936 KB Output is correct
125 Correct 49 ms 2040 KB Output is correct
126 Correct 47 ms 1912 KB Output is correct
127 Correct 40 ms 1400 KB Output is correct
128 Correct 39 ms 1144 KB Output is correct