// Comment!
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pb push_back
#define fi first
#define se second
const int maxn5 = 2e5 + 10;
vector <int> ns;
int h, w, lenh[maxn5], lenw[maxn5];
int isk(int st, int k, int n){
////cout << "here " << st << ' ' << k << ' ' << n << endl;
if(n - 1 < k)
return -1;
if(k == 0){
ns.clear();
for(int i = 0; i < n; i++)
ns.pb(i + st);
int cur = add_or(ns);
return add_not(cur);
}
//////cout << "here " << st << ' ' << k << ' ' << n << endl;
ns.clear();
int st2 = -1;
int last = -1;
for(int i = 0; i + k < n; i++){
ns.clear();
ns = {i + st, i + k + st};
//////cout << i + st << ' ' << i + k + st << ' ' << i << endl;
last = add_and(ns);
if(st2 == -1)
st2 = last;
}
//////cout << "all here " << endl;
ns.clear();
for(int i = st2; i <= last; i++)
ns.pb(i);
////cout << "well " << endl;
return add_or(ns);
}
void construct_network(int H, int W, int k) {
h = H;
w = W;
int sth = -1, last = -1;
for(int i = 0; i < h; i++){
ns.clear();
for(int j = 0; j < w; j++)
ns.pb(i * w + j);
last = add_xor(ns);
if(sth == -1)
sth = last;
}
int stw = last + 1;
for(int j = 0; j < w; j++){
ns.clear();
for(int i = 0; i < h; i++)
ns.pb(i * w + j);
last = add_xor(ns);
}
//assert(false);
memset(lenh, -1, sizeof lenh);
memset(lenw, -1, sizeof lenw);
int canh = 0, canw = 0;
for(int i = 0; i < max(h, w); i++){
if(h - 1 >= i)
canh++;
if(w - 1 >= i)
canw++;
}
int keeph = canh, keepw = canw;
////cout << "ok " << keeph << ' ' << keepw << endl;
if(keeph == 1){
int have = 0;
for(int i = 0; i <= k; i++) if(h - 1 >= i && w - 1 >= k - i)
have = i;
////cout << have << endl;
int id = isk(sth, have, h);
int id2 = isk(stw, k - have, w);
ns = {id, id2};
add_and(ns);
return;
}
if(keepw == 1){
int have = 0;
for(int i = 0; i <= k; i++) if(h - 1 >= k - i && w - 1 >= i)
have = i;
int id = isk(stw, have, w);
int id2 = isk(sth, k - have, h);
ns = {id, id2};
add_and(ns);
return;
}
////cout << "here " << endl;
for(int i = 0; i <= k; i++){
if(h - 1 >= i && w - 1 >= k - i){
if(canh == 1){
ns.clear();
for(int j = 0; j < i; j++) if(lenh[j] != -1)
ns.pb(lenh[j]);
//cout << "here " << i << endl;
if(ns.size()){
lenh[i] = add_or(ns);
lenh[i] = add_not(lenh[i]);
}
else
assert(false);
}
else
lenh[i] = isk(sth, i, h);
canh--;
}
if(w - 1 >= i && h - 1 >= k - i){
if(canw == 1){
ns.clear();
//cout << "then " << i << endl;
for(int j = 0; j < i; j++) if(lenw[j] != -1)
ns.pb(lenw[j]);
if(ns.size()){
lenw[i] = add_or(ns);
lenw[i] = add_not(lenw[i]);
}
else
assert(false);
}
else
lenw[i] = isk(stw, i, w);
canw--;
}
}
//////cout << "done with h w" << endl;
int fr = -1;
last = -1;
for(int i = 0; i <= k; i++) if(lenh[i] != -1 && lenw[k - i] != -1){
ns.clear();
ns = {lenh[i], lenw[k - i]};
last = add_and(ns);
if(fr == -1)
fr = last;
}
ns.clear();
for(int i = fr; i <= last; i++)
ns.pb(i);
add_or(ns);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
1 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1844 KB |
Output is correct |
11 |
Correct |
1 ms |
1844 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1748 KB |
Output is correct |
15 |
Correct |
1 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
1 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1844 KB |
Output is correct |
11 |
Correct |
1 ms |
1844 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1748 KB |
Output is correct |
15 |
Correct |
1 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
1 ms |
1748 KB |
Output is correct |
20 |
Correct |
1 ms |
1876 KB |
Output is correct |
21 |
Correct |
1 ms |
1876 KB |
Output is correct |
22 |
Correct |
1 ms |
1748 KB |
Output is correct |
23 |
Correct |
1 ms |
1876 KB |
Output is correct |
24 |
Correct |
1 ms |
1876 KB |
Output is correct |
25 |
Correct |
1 ms |
1876 KB |
Output is correct |
26 |
Correct |
1 ms |
1840 KB |
Output is correct |
27 |
Correct |
1 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
1 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1844 KB |
Output is correct |
11 |
Correct |
1 ms |
1844 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1748 KB |
Output is correct |
15 |
Correct |
1 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
1 ms |
1748 KB |
Output is correct |
20 |
Correct |
1 ms |
1876 KB |
Output is correct |
21 |
Correct |
1 ms |
1876 KB |
Output is correct |
22 |
Correct |
1 ms |
1748 KB |
Output is correct |
23 |
Correct |
1 ms |
1876 KB |
Output is correct |
24 |
Correct |
1 ms |
1876 KB |
Output is correct |
25 |
Correct |
1 ms |
1876 KB |
Output is correct |
26 |
Correct |
1 ms |
1840 KB |
Output is correct |
27 |
Correct |
1 ms |
1748 KB |
Output is correct |
28 |
Correct |
2 ms |
1876 KB |
Output is correct |
29 |
Correct |
1 ms |
1832 KB |
Output is correct |
30 |
Correct |
1 ms |
1844 KB |
Output is correct |
31 |
Correct |
1 ms |
1876 KB |
Output is correct |
32 |
Correct |
1 ms |
1848 KB |
Output is correct |
33 |
Correct |
2 ms |
1844 KB |
Output is correct |
34 |
Correct |
1 ms |
1848 KB |
Output is correct |
35 |
Correct |
2 ms |
1876 KB |
Output is correct |
36 |
Correct |
1 ms |
1876 KB |
Output is correct |
37 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
1 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1844 KB |
Output is correct |
11 |
Correct |
1 ms |
1844 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1748 KB |
Output is correct |
15 |
Correct |
1 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
1 ms |
1748 KB |
Output is correct |
20 |
Correct |
1 ms |
1876 KB |
Output is correct |
21 |
Correct |
1 ms |
1876 KB |
Output is correct |
22 |
Correct |
1 ms |
1748 KB |
Output is correct |
23 |
Correct |
1 ms |
1876 KB |
Output is correct |
24 |
Correct |
1 ms |
1876 KB |
Output is correct |
25 |
Correct |
1 ms |
1876 KB |
Output is correct |
26 |
Correct |
1 ms |
1840 KB |
Output is correct |
27 |
Correct |
1 ms |
1748 KB |
Output is correct |
28 |
Correct |
2 ms |
1876 KB |
Output is correct |
29 |
Correct |
1 ms |
1832 KB |
Output is correct |
30 |
Correct |
1 ms |
1844 KB |
Output is correct |
31 |
Correct |
1 ms |
1876 KB |
Output is correct |
32 |
Correct |
1 ms |
1848 KB |
Output is correct |
33 |
Correct |
2 ms |
1844 KB |
Output is correct |
34 |
Correct |
1 ms |
1848 KB |
Output is correct |
35 |
Correct |
2 ms |
1876 KB |
Output is correct |
36 |
Correct |
1 ms |
1876 KB |
Output is correct |
37 |
Correct |
1 ms |
1876 KB |
Output is correct |
38 |
Correct |
6 ms |
2640 KB |
Output is correct |
39 |
Correct |
1 ms |
1876 KB |
Output is correct |
40 |
Correct |
1 ms |
1876 KB |
Output is correct |
41 |
Correct |
2 ms |
2004 KB |
Output is correct |
42 |
Correct |
2 ms |
1848 KB |
Output is correct |
43 |
Correct |
2 ms |
2004 KB |
Output is correct |
44 |
Correct |
6 ms |
2640 KB |
Output is correct |
45 |
Incorrect |
2 ms |
2768 KB |
WA in grader: Too many instructions |
46 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1876 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1876 KB |
Output is correct |
15 |
Correct |
1 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
1 ms |
1876 KB |
Output is correct |
20 |
Correct |
1 ms |
1876 KB |
Output is correct |
21 |
Correct |
1 ms |
1748 KB |
Output is correct |
22 |
Correct |
1 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
3 ms |
2100 KB |
Output is correct |
5 |
Correct |
3 ms |
2224 KB |
Output is correct |
6 |
Correct |
2 ms |
1980 KB |
Output is correct |
7 |
Correct |
2 ms |
1848 KB |
Output is correct |
8 |
Correct |
2 ms |
2004 KB |
Output is correct |
9 |
Correct |
4 ms |
2484 KB |
Output is correct |
10 |
Correct |
4 ms |
2260 KB |
Output is correct |
11 |
Correct |
3 ms |
2132 KB |
Output is correct |
12 |
Correct |
2 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1876 KB |
Output is correct |
15 |
Correct |
1 ms |
1848 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
1 ms |
1876 KB |
Output is correct |
20 |
Correct |
4 ms |
2232 KB |
Output is correct |
21 |
Incorrect |
3 ms |
2768 KB |
WA in grader: Too many instructions |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
2 ms |
1972 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
7 |
Correct |
4 ms |
2260 KB |
Output is correct |
8 |
Correct |
4 ms |
2260 KB |
Output is correct |
9 |
Correct |
7 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
1848 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
1 ms |
1748 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1844 KB |
Output is correct |
11 |
Correct |
1 ms |
1844 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1748 KB |
Output is correct |
15 |
Correct |
1 ms |
1876 KB |
Output is correct |
16 |
Correct |
1 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
1 ms |
1748 KB |
Output is correct |
20 |
Correct |
1 ms |
1876 KB |
Output is correct |
21 |
Correct |
1 ms |
1876 KB |
Output is correct |
22 |
Correct |
1 ms |
1748 KB |
Output is correct |
23 |
Correct |
1 ms |
1876 KB |
Output is correct |
24 |
Correct |
1 ms |
1876 KB |
Output is correct |
25 |
Correct |
1 ms |
1876 KB |
Output is correct |
26 |
Correct |
1 ms |
1840 KB |
Output is correct |
27 |
Correct |
1 ms |
1748 KB |
Output is correct |
28 |
Correct |
2 ms |
1876 KB |
Output is correct |
29 |
Correct |
1 ms |
1832 KB |
Output is correct |
30 |
Correct |
1 ms |
1844 KB |
Output is correct |
31 |
Correct |
1 ms |
1876 KB |
Output is correct |
32 |
Correct |
1 ms |
1848 KB |
Output is correct |
33 |
Correct |
2 ms |
1844 KB |
Output is correct |
34 |
Correct |
1 ms |
1848 KB |
Output is correct |
35 |
Correct |
2 ms |
1876 KB |
Output is correct |
36 |
Correct |
1 ms |
1876 KB |
Output is correct |
37 |
Correct |
1 ms |
1876 KB |
Output is correct |
38 |
Correct |
6 ms |
2640 KB |
Output is correct |
39 |
Correct |
1 ms |
1876 KB |
Output is correct |
40 |
Correct |
1 ms |
1876 KB |
Output is correct |
41 |
Correct |
2 ms |
2004 KB |
Output is correct |
42 |
Correct |
2 ms |
1848 KB |
Output is correct |
43 |
Correct |
2 ms |
2004 KB |
Output is correct |
44 |
Correct |
6 ms |
2640 KB |
Output is correct |
45 |
Incorrect |
2 ms |
2768 KB |
WA in grader: Too many instructions |
46 |
Halted |
0 ms |
0 KB |
- |