#include "vision.h"
#include <bits/stdc++.h>
using namespace std ;
int cnt ;
vector <int> Ns, Ns2 ;
int pos1 = 0, pos2 = 0, var ;
set <int> st ;
int go () {
if ( min ( Ns.size(), Ns2.size() ) == 0 ) return 0 ;
add_or ( Ns ) ;
add_or ( Ns2 ) ;
add_and ( vector <int>{cnt, cnt+1} ) ;
cnt+=3 ;
}
void ini() {
Ns = vector<int>(), Ns2 = vector<int>() ;
st = set <int>() ;
}
int filCol ( int H, int W, int K, int flag ) {
for ( int i = 0 ; i < H ;++i ) {
ini() ;
for ( int j = 0 ; j < W ;++j ) Ns2.push_back ( (flag==1?i*W+j:j*H+i) );
for ( int j = 0 ; j < H ;++j ) {
if ( abs(i-j) > K )
for ( int k = 0 ; k < W; ++k ) Ns.push_back ( (flag==1?j*W+k:k*H+j) ) ;
}
go() ;
}
}
int goDiagonal ( int fil, int col, int flag, int H, int W ) {
while ( fil >= 0 && col < W ) {
if ( fil >= H || col < 0 ) {}
else{
if ( flag ) Ns.push_back ( fil*W+col ) ;
st.insert (fil*W+col);
}
fil-- ;
col++ ;
}
}
int otDiag ( int fil, int col, int flag, int H, int W ) {
while ( fil >= 0 && col >= 0 ) {
if ( fil >= H || col >= W ) {}
else{
if ( flag ) Ns.push_back ( fil*W+col ) ;
st.insert (fil*W+col);
}
fil-- ;
col-- ;
}
}
int diagDer ( int H, int W, int K ) {
for ( int i = 0 ; i < H; ++i ) {
ini() ;
goDiagonal ( i, 0,1, H, W ) ;
for ( int j = 1 ; j <= K ; ++j )
goDiagonal ( i+j, 0, 0, H, W ) ,
goDiagonal ( i-j, 0, 0, H, W ) ;
for ( int j = 0 ; j < H ; ++j ) {
for (int k = 0 ; k < W ; ++k ) {
if ( !st.count (j*W+k) ) Ns2.push_back ( j*W+k ) ;
}
}
go() ;
}
for ( int i = 0 ; i < W ; ++i ) {
ini() ;
goDiagonal ( H-1, i, 1, H, W ) ;
for ( int j = 1 ; j <= K ; ++j )
goDiagonal ( H-1, i-j, 0, H, W ) ,
goDiagonal ( H-1, i+j, 0, H, W ) ;
for ( int j = 0 ; j < H ; ++j ) {
for (int k = 0 ; k < W ; ++k ) {
if ( !st.count (j*W+k) ) Ns2.push_back ( j*W+k ) ;
}
}
go() ;
}
}
int diagIzq ( int H, int W, int K ) {
for ( int i = 0 ; i < H; ++i ) {
ini() ;
otDiag ( i, W-1,1, H, W ) ;
for ( int j = 1 ; j <= K ; ++j )
otDiag ( i+j, W-1, 0, H, W ) ,
otDiag ( i-j, W-1, 0, H, W ) ;
for ( int j = 0 ; j < H ; ++j ) {
for (int k = 0 ; k < W ; ++k ) {
if ( !st.count (j*W+k) ) Ns2.push_back ( j*W+k ) ;
}
}
go() ;
}
for ( int i = 0 ; i < W ; ++i ) {
ini() ;
otDiag ( H-1, i,1, H, W ) ;
for ( int j = 1 ; j <= K ; ++j )
otDiag ( H-1, i+j, 0, H, W ) ,
otDiag ( H-1, i-j, 0, H, W ) ;
for ( int j = 0 ; j < H ; ++j ) {
for (int k = 0 ; k < W ; ++k ) {
if ( !st.count (j*W+k) ) Ns2.push_back ( j*W+k ) ;
}
}
go() ;
}
}
void solve ( int H, int W, int K, int flag ) {
filCol ( H, W,K, 1 ) ;
filCol ( W, H,K, 0 ) ;
diagDer ( H, W, K ) ;
diagIzq ( H, W, K ) ;
vector <int> frOr ;
int cur = 0 ;
vector <int> xorAdd ;
for ( int i = 0 ; i < H ; ++i ) {
for ( int j = 0 ; j < W ;++j ) xorAdd.push_back(i*W+j) ;
}
add_xor(xorAdd) ;
add_xor(xorAdd) ;
add_xor(xorAdd) ;
cnt+=3 ;
for ( int i = var ; i < cnt ; ++i ) {
if ( cur==2 ) frOr.push_back ( i );
cur++ ;
cur%=3 ;
}
add_or ( frOr ) ;
if ( flag ) pos1 = cnt ;
else pos2 = cnt ;
cnt++ ;
var = cnt ;
}
void construct_network(int H, int W, int K) {
var = cnt = H*W ;
solve ( H, W, K, 1 ) ;
solve ( H, W, K-1, 0 ) ;
add_xor ( vector <int>{pos1,pos2} ) ;
}
Compilation message
vision.cpp: In function 'int filCol(int, int, int, int)':
vision.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
vision.cpp: In function 'int goDiagonal(int, int, int, int, int)':
vision.cpp:45:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
vision.cpp: In function 'int otDiag(int, int, int, int, int)':
vision.cpp:57:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
vision.cpp: In function 'int diagDer(int, int, int)':
vision.cpp:86:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
vision.cpp: In function 'int diagIzq(int, int, int)':
vision.cpp:115:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
vision.cpp: In function 'int go()':
vision.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
4 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
4 ms |
376 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
4 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
4 ms |
376 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
4 ms |
376 KB |
Output is correct |
28 |
Correct |
40 ms |
1656 KB |
Output is correct |
29 |
Correct |
3 ms |
376 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
16 ms |
376 KB |
Output is correct |
32 |
Correct |
16 ms |
1400 KB |
Output is correct |
33 |
Correct |
36 ms |
2936 KB |
Output is correct |
34 |
Correct |
39 ms |
1656 KB |
Output is correct |
35 |
Correct |
42 ms |
760 KB |
Output is correct |
36 |
Correct |
43 ms |
504 KB |
Output is correct |
37 |
Correct |
43 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
4 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
4 ms |
376 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
4 ms |
376 KB |
Output is correct |
28 |
Correct |
40 ms |
1656 KB |
Output is correct |
29 |
Correct |
3 ms |
376 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
16 ms |
376 KB |
Output is correct |
32 |
Correct |
16 ms |
1400 KB |
Output is correct |
33 |
Correct |
36 ms |
2936 KB |
Output is correct |
34 |
Correct |
39 ms |
1656 KB |
Output is correct |
35 |
Correct |
42 ms |
760 KB |
Output is correct |
36 |
Correct |
43 ms |
504 KB |
Output is correct |
37 |
Correct |
43 ms |
532 KB |
Output is correct |
38 |
Incorrect |
132 ms |
4664 KB |
WA in grader: Too many inputs |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
2284 KB |
Output is correct |
2 |
Correct |
20 ms |
1016 KB |
Output is correct |
3 |
Correct |
22 ms |
1016 KB |
Output is correct |
4 |
Correct |
19 ms |
376 KB |
Output is correct |
5 |
Correct |
28 ms |
2296 KB |
Output is correct |
6 |
Correct |
24 ms |
1420 KB |
Output is correct |
7 |
Correct |
22 ms |
760 KB |
Output is correct |
8 |
Correct |
20 ms |
376 KB |
Output is correct |
9 |
Correct |
28 ms |
2296 KB |
Output is correct |
10 |
Correct |
25 ms |
1656 KB |
Output is correct |
11 |
Correct |
23 ms |
1144 KB |
Output is correct |
12 |
Correct |
23 ms |
1016 KB |
Output is correct |
13 |
Correct |
20 ms |
632 KB |
Output is correct |
14 |
Correct |
19 ms |
504 KB |
Output is correct |
15 |
Correct |
30 ms |
2424 KB |
Output is correct |
16 |
Correct |
27 ms |
1656 KB |
Output is correct |
17 |
Correct |
23 ms |
1016 KB |
Output is correct |
18 |
Correct |
23 ms |
1076 KB |
Output is correct |
19 |
Correct |
22 ms |
632 KB |
Output is correct |
20 |
Correct |
20 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
18 ms |
4344 KB |
WA in grader: Too many inputs |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
4668 KB |
WA in grader: Too many inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
4 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
4 ms |
376 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
4 ms |
376 KB |
Output is correct |
28 |
Correct |
40 ms |
1656 KB |
Output is correct |
29 |
Correct |
3 ms |
376 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
16 ms |
376 KB |
Output is correct |
32 |
Correct |
16 ms |
1400 KB |
Output is correct |
33 |
Correct |
36 ms |
2936 KB |
Output is correct |
34 |
Correct |
39 ms |
1656 KB |
Output is correct |
35 |
Correct |
42 ms |
760 KB |
Output is correct |
36 |
Correct |
43 ms |
504 KB |
Output is correct |
37 |
Correct |
43 ms |
532 KB |
Output is correct |
38 |
Incorrect |
132 ms |
4664 KB |
WA in grader: Too many inputs |
39 |
Halted |
0 ms |
0 KB |
- |