Submission #146018

# Submission time Handle Problem Language Result Execution time Memory
146018 2019-08-21T15:13:27 Z oscarsierra12 Vision Program (IOI19_vision) C++14
100 / 100
64 ms 6576 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std ;

int cnt ;
vector <int> Ns;
int pos1 = 0, pos2 = 0, var ;

void ini() {
    Ns = vector<int>() ;
}

int goDiagonal ( int fil, int col, int H, int W ) {
    while ( fil >= 0 && col < W ) {
        if ( fil >= H || col < 0 ) {}
        else
            Ns.push_back ( fil*W+col ) ;
        fil-- ;
        col++ ;
    }
}

int otDiag ( int fil, int col, int H, int W ) {
    while ( fil >= 0 && col >= 0 ) {
        if ( fil >= H || col >= W ) {}
        else
            Ns.push_back ( fil*W+col ) ;
        fil-- ;
        col-- ;
    }
}

int diagDer ( int H, int W, int K ) {
    ini() ;
    goDiagonal(H-1, W-K-2, H, W) ;
    if ( Ns.size() ) {
        add_or( Ns ) ;
        ini() ;
        goDiagonal(H-1, W-1, H, W );
        add_or ( Ns ) ;
        add_and(vector<int>{cnt, cnt+1}) ;
        cnt+=3 ;
    }
    for ( int i = W-K-3 ; i > -H ; --i ) {
        ini() ;
        goDiagonal ( H-1, i, H, W ) ;
        add_or ( Ns ) ;
        ini() ;
        goDiagonal ( H-1, i+K+1, H, W ) ;
        Ns.push_back ( cnt-2 ) ;
        add_or ( Ns ) ;
        add_and(vector<int>{cnt, cnt+1}) ;
        cnt+=3 ;
    }
}

int diagIzq ( int H, int W, int K ) {
    ini() ;
    otDiag ( H-1, W+H-K-3, H, W ) ;
    if ( Ns.size() ) {
        add_or( Ns ) ;
        ini() ;
        otDiag(H-1, W+H-2, H, W );
        add_or ( Ns ) ;
        add_and(vector<int>{cnt, cnt+1}) ;
        cnt+=3 ;
    }
    for ( int i = W+H-K-4 ; i >= 0 ; --i ) {
        ini() ;
        otDiag ( H-1, i, H, W ) ;
        add_or ( Ns ) ;
        ini() ;
        otDiag ( H-1, i+K+1, H, W ) ;
        Ns.push_back ( cnt-2 ) ;
        add_or ( Ns ) ;
        add_and(vector<int>{cnt, cnt+1}) ;
        cnt+=3 ;
    }
}

void solve ( int H, int W, int K, int flag ) {
    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 goDiagonal(int, int, int, int)':
vision.cpp:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
vision.cpp: In function 'int otDiag(int, int, int, int)':
vision.cpp:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
vision.cpp: In function 'int diagDer(int, int, int)':
vision.cpp:55:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
vision.cpp: In function 'int diagIzq(int, int, int)':
vision.cpp:79:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 252 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 252 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 4 ms 632 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 4 ms 376 KB Output is correct
36 Correct 1 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 252 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 4 ms 632 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 4 ms 376 KB Output is correct
36 Correct 1 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 16 ms 1656 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 11 ms 1144 KB Output is correct
42 Correct 5 ms 632 KB Output is correct
43 Correct 18 ms 1780 KB Output is correct
44 Correct 17 ms 1656 KB Output is correct
45 Correct 13 ms 1400 KB Output is correct
46 Correct 10 ms 1144 KB Output is correct
47 Correct 8 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 380 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 4 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 4 ms 592 KB Output is correct
16 Correct 4 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 7 ms 764 KB Output is correct
4 Correct 7 ms 760 KB Output is correct
5 Correct 6 ms 632 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 13 ms 1272 KB Output is correct
9 Correct 11 ms 1144 KB Output is correct
10 Correct 10 ms 1016 KB Output is correct
11 Correct 7 ms 888 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 4 ms 504 KB Output is correct
14 Correct 3 ms 484 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 34 ms 3428 KB Output is correct
21 Correct 28 ms 2972 KB Output is correct
22 Correct 26 ms 2140 KB Output is correct
23 Correct 14 ms 1820 KB Output is correct
24 Correct 33 ms 3484 KB Output is correct
25 Correct 24 ms 2460 KB Output is correct
26 Correct 14 ms 1692 KB Output is correct
27 Correct 63 ms 6444 KB Output is correct
28 Correct 58 ms 6072 KB Output is correct
29 Correct 45 ms 4852 KB Output is correct
30 Correct 32 ms 3640 KB Output is correct
31 Correct 26 ms 3252 KB Output is correct
32 Correct 3 ms 380 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 6444 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 8 ms 760 KB Output is correct
4 Correct 12 ms 1272 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 34 ms 3336 KB Output is correct
8 Correct 33 ms 3360 KB Output is correct
9 Correct 63 ms 6444 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 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 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 252 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 4 ms 632 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 4 ms 376 KB Output is correct
36 Correct 1 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 16 ms 1656 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 11 ms 1144 KB Output is correct
42 Correct 5 ms 632 KB Output is correct
43 Correct 18 ms 1780 KB Output is correct
44 Correct 17 ms 1656 KB Output is correct
45 Correct 13 ms 1400 KB Output is correct
46 Correct 10 ms 1144 KB Output is correct
47 Correct 8 ms 1016 KB Output is correct
48 Correct 3 ms 504 KB Output is correct
49 Correct 3 ms 376 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 2 ms 476 KB Output is correct
52 Correct 4 ms 504 KB Output is correct
53 Correct 3 ms 504 KB Output is correct
54 Correct 3 ms 380 KB Output is correct
55 Correct 3 ms 376 KB Output is correct
56 Correct 4 ms 504 KB Output is correct
57 Correct 3 ms 504 KB Output is correct
58 Correct 3 ms 504 KB Output is correct
59 Correct 3 ms 504 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 2 ms 376 KB Output is correct
62 Correct 4 ms 592 KB Output is correct
63 Correct 4 ms 504 KB Output is correct
64 Correct 3 ms 504 KB Output is correct
65 Correct 3 ms 504 KB Output is correct
66 Correct 3 ms 376 KB Output is correct
67 Correct 2 ms 376 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 2 ms 376 KB Output is correct
70 Correct 2 ms 376 KB Output is correct
71 Correct 2 ms 256 KB Output is correct
72 Correct 7 ms 764 KB Output is correct
73 Correct 7 ms 760 KB Output is correct
74 Correct 6 ms 632 KB Output is correct
75 Correct 4 ms 632 KB Output is correct
76 Correct 4 ms 504 KB Output is correct
77 Correct 13 ms 1272 KB Output is correct
78 Correct 11 ms 1144 KB Output is correct
79 Correct 10 ms 1016 KB Output is correct
80 Correct 7 ms 888 KB Output is correct
81 Correct 5 ms 632 KB Output is correct
82 Correct 4 ms 504 KB Output is correct
83 Correct 3 ms 484 KB Output is correct
84 Correct 3 ms 376 KB Output is correct
85 Correct 2 ms 376 KB Output is correct
86 Correct 4 ms 504 KB Output is correct
87 Correct 3 ms 504 KB Output is correct
88 Correct 2 ms 376 KB Output is correct
89 Correct 34 ms 3428 KB Output is correct
90 Correct 28 ms 2972 KB Output is correct
91 Correct 26 ms 2140 KB Output is correct
92 Correct 14 ms 1820 KB Output is correct
93 Correct 33 ms 3484 KB Output is correct
94 Correct 24 ms 2460 KB Output is correct
95 Correct 14 ms 1692 KB Output is correct
96 Correct 63 ms 6444 KB Output is correct
97 Correct 58 ms 6072 KB Output is correct
98 Correct 45 ms 4852 KB Output is correct
99 Correct 32 ms 3640 KB Output is correct
100 Correct 26 ms 3252 KB Output is correct
101 Correct 3 ms 380 KB Output is correct
102 Correct 2 ms 376 KB Output is correct
103 Correct 63 ms 6444 KB Output is correct
104 Correct 2 ms 380 KB Output is correct
105 Correct 8 ms 760 KB Output is correct
106 Correct 12 ms 1272 KB Output is correct
107 Correct 4 ms 504 KB Output is correct
108 Correct 4 ms 504 KB Output is correct
109 Correct 34 ms 3336 KB Output is correct
110 Correct 33 ms 3360 KB Output is correct
111 Correct 63 ms 6444 KB Output is correct
112 Correct 3 ms 256 KB Output is correct
113 Correct 2 ms 376 KB Output is correct
114 Correct 61 ms 6072 KB Output is correct
115 Correct 2 ms 376 KB Output is correct
116 Correct 4 ms 632 KB Output is correct
117 Correct 16 ms 1820 KB Output is correct
118 Correct 32 ms 3320 KB Output is correct
119 Correct 44 ms 4792 KB Output is correct
120 Correct 46 ms 4652 KB Output is correct
121 Correct 46 ms 4776 KB Output is correct
122 Correct 45 ms 4796 KB Output is correct
123 Correct 64 ms 6576 KB Output is correct
124 Correct 59 ms 6068 KB Output is correct
125 Correct 45 ms 4792 KB Output is correct
126 Correct 45 ms 4784 KB Output is correct
127 Correct 32 ms 3572 KB Output is correct
128 Correct 27 ms 3328 KB Output is correct