Submission #615962

# Submission time Handle Problem Language Result Execution time Memory
615962 2022-07-31T16:20:38 Z neki Vision Program (IOI19_vision) C++14
100 / 100
97 ms 10860 KB
#include "vision.h"
#include <bits/stdc++.h>
#define vc vector
#define ll int
#define loop(i, a, b) for(ll i=a;i<b;++i)

using namespace std;

/*vc<ll> zac={1, 0, 0, 0,    
            0, 0, 0, 0,    
            0, 0, 0, 1};

void add_and(vc<ll> a){zac.push_back(1); for(auto v: a) assert(v<zac.size()), zac[zac.size()-1]&=zac[v];};
void add_or(vc<ll> a ){zac.push_back(0); for(auto v: a) assert(v<zac.size()), zac[zac.size()-1]|=zac[v];};
void add_xor(vc<ll> a){zac.push_back(0); for(auto v: a) assert(v<zac.size()), zac[zac.size()-1]^=zac[v];};
void add_not(ll a){assert(a<zac.size()), zac.push_back(!zac[a]);};*/

void construct_network(int h, int w, int k){
    ll cur=h * w;
    function<ll (ll)> less=[&](ll d){
        function<ll (vc<vc<ll>>)> preglejdiag=[&](vc<vc<ll>> kje){
            
            vc<ll> dor, dxor;
            for(ll i=0;i<h+w-1;++i){
                vc<ll> que;
                for(ll x=i, y=0;x>=0;--x, ++y) if(x<h and y<w){
                    
                    que.push_back(kje[x][y]);
                    //cout << kje[x][y] << endl;
                }
                //cout << endl;
                dor.push_back(cur++);add_or(que);
                //cout << zac[dor[i]]<<" ";
                dxor.push_back(cur++);add_xor(que);
            }
            //cout << endl;
            //for(auto v: dor) cout << zac[v] << " ";cout << endl;
            
            vc<ll> blor, blxor;
            for(ll i=0;i<h+w-1;++i){
                vc<ll> que;
                for(ll j=i;j<h+w-1 and j<=i+d;++j) que.push_back(dor[j]);
                blor.push_back(cur++);add_or(que);
            }
            for(ll i=0;i<h+w-1;++i){
                vc<ll> que;
                for(ll j=i;j<h+w-1 and j<=i+d;++j) que.push_back(dxor[j]);
                ll temp=cur++; add_xor(que);
                blxor.push_back(cur++);add_not(temp);
            }
            assert(blor.size()==blxor.size());
            
            vc<ll> vand;
            for(ll i=0;i<blor.size();++i) vand.push_back(cur++), add_and({blor[i], blxor[i]});
        
            add_or(vand);
            
            return cur++;
        };
        vc<vc<ll>> pkje(h, vc<ll>(w)), nkje(h, vc<ll>(w));
        for(ll i=0, cnt=0;i<h;++i) for(ll j=0;j<w;++j) pkje[i][j]=cnt++;
        for(ll i=h-1, cnt=0;i>=0;--i) for(ll j=0;j<w;++j) nkje[i][j]=cnt++;
        
        add_and({preglejdiag(pkje), preglejdiag(nkje)});
        return cur++;
    };
    
    if(k==1) less(1);
    else{
        ll manj=less(k-1);
        add_not(manj);ll nmanj=cur++;
        ll temp=less(k);
        
        //cout << zac[manj] << " "<< zac[temp] << endl;
        
        
        add_and({nmanj, temp});
    }
}

Compilation message

vision.cpp: In lambda function:
vision.cpp:54:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             for(ll i=0;i<blor.size();++i) vand.push_back(cur++), add_and({blor[i], blxor[i]});
      |                        ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 300 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 3 ms 468 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 300 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 3 ms 468 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 20 ms 2128 KB Output is correct
39 Correct 3 ms 556 KB Output is correct
40 Correct 5 ms 724 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
42 Correct 17 ms 1668 KB Output is correct
43 Correct 5 ms 980 KB Output is correct
44 Correct 16 ms 2128 KB Output is correct
45 Correct 20 ms 2544 KB Output is correct
46 Correct 24 ms 2912 KB Output is correct
47 Correct 30 ms 3016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 12 ms 1584 KB Output is correct
3 Correct 12 ms 1676 KB Output is correct
4 Correct 15 ms 1960 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 13 ms 1388 KB Output is correct
7 Correct 14 ms 1832 KB Output is correct
8 Correct 18 ms 2000 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 9 ms 1156 KB Output is correct
11 Correct 16 ms 1620 KB Output is correct
12 Correct 13 ms 1616 KB Output is correct
13 Correct 15 ms 1872 KB Output is correct
14 Correct 16 ms 1932 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 11 ms 1192 KB Output is correct
17 Correct 13 ms 1616 KB Output is correct
18 Correct 13 ms 1712 KB Output is correct
19 Correct 15 ms 1992 KB Output is correct
20 Correct 20 ms 2000 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 7 ms 916 KB Output is correct
5 Correct 8 ms 1196 KB Output is correct
6 Correct 9 ms 1236 KB Output is correct
7 Correct 9 ms 1236 KB Output is correct
8 Correct 5 ms 724 KB Output is correct
9 Correct 12 ms 1488 KB Output is correct
10 Correct 17 ms 1968 KB Output is correct
11 Correct 18 ms 2020 KB Output is correct
12 Correct 18 ms 2120 KB Output is correct
13 Correct 2 ms 468 KB Output is correct
14 Correct 9 ms 1316 KB Output is correct
15 Correct 14 ms 1872 KB Output is correct
16 Correct 16 ms 2032 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 12 ms 1616 KB Output is correct
19 Correct 16 ms 2056 KB Output is correct
20 Correct 9 ms 1492 KB Output is correct
21 Correct 34 ms 4468 KB Output is correct
22 Correct 46 ms 5688 KB Output is correct
23 Correct 54 ms 6064 KB Output is correct
24 Correct 9 ms 1576 KB Output is correct
25 Correct 41 ms 5064 KB Output is correct
26 Correct 50 ms 6064 KB Output is correct
27 Correct 17 ms 2664 KB Output is correct
28 Correct 64 ms 7168 KB Output is correct
29 Correct 80 ms 9216 KB Output is correct
30 Correct 83 ms 10436 KB Output is correct
31 Correct 89 ms 10820 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2612 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 10 ms 1584 KB Output is correct
8 Correct 9 ms 1492 KB Output is correct
9 Correct 17 ms 2644 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 292 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 296 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 300 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 3 ms 468 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 20 ms 2128 KB Output is correct
39 Correct 3 ms 556 KB Output is correct
40 Correct 5 ms 724 KB Output is correct
41 Correct 6 ms 980 KB Output is correct
42 Correct 17 ms 1668 KB Output is correct
43 Correct 5 ms 980 KB Output is correct
44 Correct 16 ms 2128 KB Output is correct
45 Correct 20 ms 2544 KB Output is correct
46 Correct 24 ms 2912 KB Output is correct
47 Correct 30 ms 3016 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 12 ms 1584 KB Output is correct
50 Correct 12 ms 1676 KB Output is correct
51 Correct 15 ms 1960 KB Output is correct
52 Correct 3 ms 724 KB Output is correct
53 Correct 13 ms 1388 KB Output is correct
54 Correct 14 ms 1832 KB Output is correct
55 Correct 18 ms 2000 KB Output is correct
56 Correct 2 ms 468 KB Output is correct
57 Correct 9 ms 1156 KB Output is correct
58 Correct 16 ms 1620 KB Output is correct
59 Correct 13 ms 1616 KB Output is correct
60 Correct 15 ms 1872 KB Output is correct
61 Correct 16 ms 1932 KB Output is correct
62 Correct 1 ms 468 KB Output is correct
63 Correct 11 ms 1192 KB Output is correct
64 Correct 13 ms 1616 KB Output is correct
65 Correct 13 ms 1712 KB Output is correct
66 Correct 15 ms 1992 KB Output is correct
67 Correct 20 ms 2000 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 7 ms 916 KB Output is correct
74 Correct 8 ms 1196 KB Output is correct
75 Correct 9 ms 1236 KB Output is correct
76 Correct 9 ms 1236 KB Output is correct
77 Correct 5 ms 724 KB Output is correct
78 Correct 12 ms 1488 KB Output is correct
79 Correct 17 ms 1968 KB Output is correct
80 Correct 18 ms 2020 KB Output is correct
81 Correct 18 ms 2120 KB Output is correct
82 Correct 2 ms 468 KB Output is correct
83 Correct 9 ms 1316 KB Output is correct
84 Correct 14 ms 1872 KB Output is correct
85 Correct 16 ms 2032 KB Output is correct
86 Correct 2 ms 468 KB Output is correct
87 Correct 12 ms 1616 KB Output is correct
88 Correct 16 ms 2056 KB Output is correct
89 Correct 9 ms 1492 KB Output is correct
90 Correct 34 ms 4468 KB Output is correct
91 Correct 46 ms 5688 KB Output is correct
92 Correct 54 ms 6064 KB Output is correct
93 Correct 9 ms 1576 KB Output is correct
94 Correct 41 ms 5064 KB Output is correct
95 Correct 50 ms 6064 KB Output is correct
96 Correct 17 ms 2664 KB Output is correct
97 Correct 64 ms 7168 KB Output is correct
98 Correct 80 ms 9216 KB Output is correct
99 Correct 83 ms 10436 KB Output is correct
100 Correct 89 ms 10820 KB Output is correct
101 Correct 1 ms 212 KB Output is correct
102 Correct 1 ms 304 KB Output is correct
103 Correct 22 ms 2612 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 2 ms 468 KB Output is correct
106 Correct 4 ms 724 KB Output is correct
107 Correct 1 ms 468 KB Output is correct
108 Correct 2 ms 468 KB Output is correct
109 Correct 10 ms 1584 KB Output is correct
110 Correct 9 ms 1492 KB Output is correct
111 Correct 17 ms 2644 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 59 ms 7280 KB Output is correct
115 Correct 16 ms 2000 KB Output is correct
116 Correct 3 ms 724 KB Output is correct
117 Correct 47 ms 5928 KB Output is correct
118 Correct 34 ms 3704 KB Output is correct
119 Correct 72 ms 9104 KB Output is correct
120 Correct 71 ms 9180 KB Output is correct
121 Correct 91 ms 9152 KB Output is correct
122 Correct 73 ms 9144 KB Output is correct
123 Correct 16 ms 2640 KB Output is correct
124 Correct 57 ms 7204 KB Output is correct
125 Correct 78 ms 9176 KB Output is correct
126 Correct 73 ms 9152 KB Output is correct
127 Correct 97 ms 10332 KB Output is correct
128 Correct 87 ms 10860 KB Output is correct