#include "vision.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
int id[405][405], last, zero;
void construct_network(int H, int W, int K)
{
if (H * W == 2)
return;
last = H * W;
for (int i = 1; i < H + W; i++)
for (int j = 1; j < H + W; j++)
id[i][j] = -1;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
id[j + i + 1][H - i + j] = i * W + j;
vector<int> Hs(H + W), Ws(H + W);
for (int i = 1; i < H + W; i++)
{
vector<int> input;
for (int j = 1; j < H + W; j++)
if (id[i][j] >= 0)
input.emplace_back(id[i][j]);
Hs[i] = last++;
add_or(input);
}
for (int j = 1; j < H + W; j++)
{
vector<int> input;
for (int i = 1; i < H + W; i++)
if (id[i][j] >= 0)
input.emplace_back(id[i][j]);
Ws[j] = last++;
add_or(input);
}
vector<int> HeqK, HgeK, WeqK, WgeK;
for (int i = 1; i + K < H + W; i++)
{
HeqK.emplace_back(last++);
add_and({Hs[i], Hs[i + K]});
}
for (int j = 1; j + K < H + W; j++)
{
WeqK.emplace_back(last++);
add_and({Ws[j], Ws[j + K]});
}
for (int i = 1; i + K + 1 < H + W; i++)
{
vector<int> input;
for (int j = i + K + 1; j < H + W; j++)
input.emplace_back(Hs[j]);
add_or(input);
++last;
add_and({Hs[i], last - 1});
HgeK.emplace_back(last++);
}
for (int i = 1; i + K + 1 < H + W; i++)
{
vector<int> input;
for (int j = i + K + 1; j < H + W; j++)
input.emplace_back(Ws[j]);
add_or(input);
++last;
add_and({Ws[i], last - 1});
WgeK.emplace_back(last++);
}
if (HeqK.empty())
add_and({0, 1, 2});
else
add_or(HeqK);
if (WeqK.empty())
add_and({0, 1, 2});
else
add_or(WeqK);
if (HgeK.empty())
add_and({0, 1, 2});
else
add_or(HgeK);
if (WgeK.empty())
add_and({0, 1, 2});
else
add_or(WgeK);
add_or({last, last + 1}); // last + 4 = if dis == K
add_not(last + 2); // last + 5 = if H <= K
add_not(last + 3); // last + 6 = if W <= K
add_and({last + 4, last + 5, last + 6});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1064 KB |
Output is correct |
2 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
3 ms |
688 KB |
Output is correct |
4 |
Correct |
1 ms |
596 KB |
Output is correct |
5 |
Correct |
5 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
852 KB |
Output is correct |
7 |
Correct |
2 ms |
724 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
8 ms |
1076 KB |
Output is correct |
10 |
Correct |
3 ms |
852 KB |
Output is correct |
11 |
Correct |
2 ms |
724 KB |
Output is correct |
12 |
Correct |
2 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
5 ms |
1072 KB |
Output is correct |
16 |
Correct |
4 ms |
852 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 |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
596 KB |
Output is correct |
21 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
3 ms |
820 KB |
Output is correct |
4 |
Correct |
3 ms |
596 KB |
Output is correct |
5 |
Correct |
2 ms |
564 KB |
Output is correct |
6 |
Correct |
1 ms |
564 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
8 ms |
980 KB |
Output is correct |
9 |
Correct |
4 ms |
852 KB |
Output is correct |
10 |
Correct |
3 ms |
816 KB |
Output is correct |
11 |
Correct |
2 ms |
724 KB |
Output is correct |
12 |
Correct |
2 ms |
596 KB |
Output is correct |
13 |
Correct |
7 ms |
980 KB |
Output is correct |
14 |
Correct |
5 ms |
852 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
596 KB |
Output is correct |
17 |
Correct |
5 ms |
980 KB |
Output is correct |
18 |
Correct |
3 ms |
724 KB |
Output is correct |
19 |
Correct |
2 ms |
596 KB |
Output is correct |
20 |
Correct |
19 ms |
2180 KB |
Output is correct |
21 |
Correct |
9 ms |
1620 KB |
Output is correct |
22 |
Correct |
6 ms |
1236 KB |
Output is correct |
23 |
Correct |
5 ms |
1076 KB |
Output is correct |
24 |
Correct |
14 ms |
2224 KB |
Output is correct |
25 |
Correct |
7 ms |
1492 KB |
Output is correct |
26 |
Correct |
5 ms |
1132 KB |
Output is correct |
27 |
Correct |
25 ms |
3532 KB |
Output is correct |
28 |
Correct |
20 ms |
2772 KB |
Output is correct |
29 |
Correct |
17 ms |
2224 KB |
Output is correct |
30 |
Correct |
11 ms |
1876 KB |
Output is correct |
31 |
Correct |
9 ms |
1760 KB |
Output is correct |
32 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3432 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
820 KB |
Output is correct |
4 |
Correct |
6 ms |
1076 KB |
Output is correct |
5 |
Correct |
5 ms |
980 KB |
Output is correct |
6 |
Correct |
5 ms |
1080 KB |
Output is correct |
7 |
Correct |
16 ms |
2200 KB |
Output is correct |
8 |
Correct |
15 ms |
2184 KB |
Output is correct |
9 |
Correct |
24 ms |
3500 KB |
Output is correct |
10 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Integer parameter [name=num_gates] equals to 0, violates the range [1, 10000] |
18 |
Halted |
0 ms |
0 KB |
- |