#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
#define mp make_pair
#define all(x) x.begin(),x.end()
void construct_network(int n, int m, int K) {
map<int,int> diagdw,diagup;
for(int it = 0; it <= n+m-2; it++) {
int i,j;
if(it <= n-1) {
i = n-1-it;
j = 0;
}
else {
i = 0;
j = it-n+1;
}
int i0,j0;
vector<int> diag;
i0 = i-i;
j0 = j-i;
while(i0 <= n-1) {
if(i0 >= 0 && i0 <= n-1 && j0 >= 0 && j0 <= m-1) diag.pb(i0*m+j0);
i0++;
j0++;
}
diagdw[i-j] = add_or(diag);
if(it <= n-1) {
i = it;
j = 0;
}
else {
i = n-1;
j = it-n+1;
}
diag.clear();
i0 = i-i;
j0 = j+i;
while(i0 <= n-1) {
if(i0 >= 0 && i0 <= n-1 && j0 >= 0 && j0 <= m-1) diag.pb(i0*m+j0);
i0++;
j0--;
}
diagup[i] = add_or(diag);
}
vector<int> checks0;
for(int add = 0; K+add <= n+m-2 && add <= 1; add+= 1) {
int k = K+add;
vector<int> checks;
for(int it = 0; it <= n+m-2; it++) {
int i,j;
if(it <= n-1) {
i = n-1-it;
j = 0;
}
else {
i = 0;
j = it-n+1;
}
vector<int> diag0,diag1;
int i0,j0,i1,j1;
i0 = i-i;
j0 = j-i;
i1 = i-i;
j1 = j+k-i;
while(i0 <= n-1) {
// if(i0 >= 0 && i0 <= n-1 && j0 >= 0 && j0 <= m-1) diag0.pb(i0*m+j0);
for(int jj = 0; jj <= j0; jj++) {
if(i0 >= 0 && i0 <= n-1 && jj >= 0 && jj <= m-1) diag0.pb(i0*m+jj);
}
i0++;
j0++;
}
while(i1 <= n-1) {
// if(i1 >= 0 && i1 <= n-1 && j1 >= 0 && j1 <= m-1) diag1.pb(i1*m+j1);
for(int jj = j1; jj <= m-1; jj++) {
if(i1 >= 0 && i1 <= n-1 && jj >= 0 && jj <= m-1) diag1.pb(i1*m+jj);
}
i1++;
j1++;
}
if(diag0.size() && diag1.size()) checks.pb(add_and(vector<int>{add_or(diag0),add_or(diag1)}));
for(auto x : diag0) {
// cout << " ++ " << x/m << " " << x%m << endl;
}
for(auto x : diag1) {
// cout << " -- " << x/m << " " << x%m << endl;
}
diag0.clear();
diag1.clear();
if(it <= n-1) {
i = it;
j = 0;
}
else {
i = n-1;
j = it-n+1;
}
i0 = i-i;
j0 = j+i;
i1 = i-i;
j1 = j+k+i;
// cout << i << " " << j << endl;
while(i0 <= n-1) {
// if(i0 >= 0 && i0 <= n-1 && j0 >= 0 && j0 <= m-1) diag0.pb(i0*m+j0);
for(int jj = 0; jj <= j0; jj++) {
if(i0 >= 0 && i0 <= n-1 && jj >= 0 && jj <= m-1) diag0.pb(i0*m+jj);
}
i0++;
j0--;
}
while(i1 <= n-1) {
// if(i1 >= 0 && i1 <= n-1 && j1 >= 0 && j1 <= m-1) diag1.pb(i1*m+j1);
for(int jj = j1; jj <= m-1; jj++) {
if(i1 >= 0 && i1 <= n-1 && jj >= 0 && jj <= m-1) diag1.pb(i1*m+jj);
}
i1++;
j1--;
}
if(diag0.size() && diag1.size()) checks.pb(add_and(vector<int>{add_or(diag0),add_or(diag1)}));
}
if(add == 0) checks0.pb(add_or(checks));
else checks0.pb(add_not(add_or(checks)));
}
add_and(checks0);
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:103:13: warning: unused variable 'x' [-Wunused-variable]
103 | for(auto x : diag0) {
| ^
vision.cpp:106:13: warning: unused variable 'x' [-Wunused-variable]
106 | for(auto x : diag1) {
| ^
# |
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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 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 |
0 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 |
232 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 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 |
0 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 |
232 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
256 KB |
Output is correct |
28 |
Correct |
10 ms |
1196 KB |
Output is correct |
29 |
Correct |
1 ms |
296 KB |
Output is correct |
30 |
Correct |
1 ms |
296 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
7 ms |
852 KB |
Output is correct |
33 |
Correct |
23 ms |
1960 KB |
Output is correct |
34 |
Correct |
9 ms |
1204 KB |
Output is correct |
35 |
Correct |
5 ms |
596 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 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 |
0 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 |
232 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
256 KB |
Output is correct |
28 |
Correct |
10 ms |
1196 KB |
Output is correct |
29 |
Correct |
1 ms |
296 KB |
Output is correct |
30 |
Correct |
1 ms |
296 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
7 ms |
852 KB |
Output is correct |
33 |
Correct |
23 ms |
1960 KB |
Output is correct |
34 |
Correct |
9 ms |
1204 KB |
Output is correct |
35 |
Correct |
5 ms |
596 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Incorrect |
4 ms |
4436 KB |
WA in grader: Too many inputs |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
1640 KB |
Output is correct |
2 |
Correct |
4 ms |
680 KB |
Output is correct |
3 |
Correct |
6 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
28 ms |
1604 KB |
Output is correct |
6 |
Correct |
11 ms |
852 KB |
Output is correct |
7 |
Correct |
6 ms |
492 KB |
Output is correct |
8 |
Correct |
4 ms |
340 KB |
Output is correct |
9 |
Correct |
14 ms |
1620 KB |
Output is correct |
10 |
Correct |
9 ms |
1188 KB |
Output is correct |
11 |
Correct |
4 ms |
596 KB |
Output is correct |
12 |
Correct |
6 ms |
596 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
24 ms |
1580 KB |
Output is correct |
16 |
Correct |
12 ms |
1108 KB |
Output is correct |
17 |
Correct |
11 ms |
640 KB |
Output is correct |
18 |
Correct |
8 ms |
724 KB |
Output is correct |
19 |
Correct |
5 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
6 ms |
4264 KB |
WA in grader: Too many inputs |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
4636 KB |
WA in grader: Too many inputs |
2 |
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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 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 |
0 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 |
232 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
256 KB |
Output is correct |
28 |
Correct |
10 ms |
1196 KB |
Output is correct |
29 |
Correct |
1 ms |
296 KB |
Output is correct |
30 |
Correct |
1 ms |
296 KB |
Output is correct |
31 |
Correct |
1 ms |
212 KB |
Output is correct |
32 |
Correct |
7 ms |
852 KB |
Output is correct |
33 |
Correct |
23 ms |
1960 KB |
Output is correct |
34 |
Correct |
9 ms |
1204 KB |
Output is correct |
35 |
Correct |
5 ms |
596 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Incorrect |
4 ms |
4436 KB |
WA in grader: Too many inputs |
39 |
Halted |
0 ms |
0 KB |
- |