Submission #1059143

# Submission time Handle Problem Language Result Execution time Memory
1059143 2024-08-14T17:46:05 Z efishel Vision Program (IOI19_vision) C++17
100 / 100
22 ms 5472 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;

const ll MAXN = 500;
vll wh1[MAXN], wh2[MAXN];

void construct_network (int h, int w, int k) {
    auto toLine = [&](ll i, ll j) { return 0 <= i && i < h && 0 <= j && j < w ? i*w+j : -16; };
    if (k == h+w-2) {
        add_or({ add_and({ toLine(0, 0), toLine(h-1, w-1) }), add_and({ toLine(h-1, 0), toLine(0, w-1) }) });
        return;
    }
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            wh1[i+j].push_back(toLine(i, j));
            wh2[j+h-1-i].push_back(toLine(i, j));
        }
    }
    vi diag1, diag2;
    for (ll i = 0; i < h+w-1; i++) {
        diag1.push_back(add_or(vi(wh1[i].begin(), wh1[i].end())));
        diag2.push_back(add_or(vi(wh2[i].begin(), wh2[i].end())));
    }
    vi op1, op2;
    // or op1: dis in diag1 == k
    // or op2: dis in diag2 == k
    for (ll i = k; i < h+w-1; i++) {
        op1.push_back(add_and({ diag1[i-k], diag1[i] }));
        op2.push_back(add_and({ diag2[i-k], diag2[i] }));
    }
    vi bd1, bd2;
    // or bd1: dis in diag1 > k
    // or bd2: dis in diag2 > k
    for (ll i = k; i < h+w-1 - 1; i++) {
        ll p1 = i-k+1, p2 = i;
        bd1.push_back(add_and({ add_or(vi(diag1.begin(), diag1.begin()+p1-1+1)), add_or(vi(diag1.begin()+p2+1, diag1.end())) }));
        bd2.push_back(add_and({ add_or(vi(diag2.begin(), diag2.begin()+p1-1+1)), add_or(vi(diag2.begin()+p2+1, diag2.end())) }));
    }
    add_and({ add_not({ add_or(bd1) }), add_not({ add_or(bd2) }), add_or({ add_or(op1), add_or(op2) }) });
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:14:34: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(0, 0)' from 'long long int' to 'int' [-Wnarrowing]
   14 |         add_or({ add_and({ toLine(0, 0), toLine(h-1, w-1) }), add_and({ toLine(h-1, 0), toLine(0, w-1) }) });
      |                            ~~~~~~^~~~~~
vision.cpp:14:34: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(0, 0)' from 'long long int' to 'int' [-Wnarrowing]
vision.cpp:14:48: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(((ll)(h - 1)), ((ll)(w - 1)))' from 'long long int' to 'int' [-Wnarrowing]
   14 |         add_or({ add_and({ toLine(0, 0), toLine(h-1, w-1) }), add_and({ toLine(h-1, 0), toLine(0, w-1) }) });
      |                                          ~~~~~~^~~~~~~~~~
vision.cpp:14:48: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(((ll)(h - 1)), ((ll)(w - 1)))' from 'long long int' to 'int' [-Wnarrowing]
vision.cpp:14:79: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(((ll)(h - 1)), 0)' from 'long long int' to 'int' [-Wnarrowing]
   14 |         add_or({ add_and({ toLine(0, 0), toLine(h-1, w-1) }), add_and({ toLine(h-1, 0), toLine(0, w-1) }) });
      |                                                                         ~~~~~~^~~~~~~~
vision.cpp:14:79: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(((ll)(h - 1)), 0)' from 'long long int' to 'int' [-Wnarrowing]
vision.cpp:14:95: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(0, ((ll)(w - 1)))' from 'long long int' to 'int' [-Wnarrowing]
   14 |         add_or({ add_and({ toLine(0, 0), toLine(h-1, w-1) }), add_and({ toLine(h-1, 0), toLine(0, w-1) }) });
      |                                                                                         ~~~~~~^~~~~~~~
vision.cpp:14:95: warning: narrowing conversion of 'toLine.construct_network(int, int, int)::<lambda(ll, ll)>(0, ((ll)(w - 1)))' from 'long long int' to 'int' [-Wnarrowing]
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 464 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 464 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 492 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 464 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 492 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 4 ms 1376 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 3 ms 1116 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 5 ms 1624 KB Output is correct
44 Correct 4 ms 1372 KB Output is correct
45 Correct 2 ms 1056 KB Output is correct
46 Correct 2 ms 856 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1116 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 1116 KB Output is correct
6 Correct 4 ms 856 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 1408 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 4 ms 1112 KB Output is correct
16 Correct 3 ms 856 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 360 KB Output is correct
8 Correct 4 ms 1372 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 4 ms 1116 KB Output is correct
14 Correct 3 ms 860 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 4 ms 1228 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 10 ms 3220 KB Output is correct
21 Correct 6 ms 2140 KB Output is correct
22 Correct 5 ms 1628 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 10 ms 3272 KB Output is correct
25 Correct 4 ms 1880 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 19 ms 5472 KB Output is correct
28 Correct 13 ms 4188 KB Output is correct
29 Correct 8 ms 2908 KB Output is correct
30 Correct 5 ms 2396 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 5468 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 4 ms 1340 KB Output is correct
5 Correct 4 ms 1112 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 10 ms 3164 KB Output is correct
8 Correct 10 ms 3280 KB Output is correct
9 Correct 19 ms 5468 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 460 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 464 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 492 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 4 ms 1376 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 3 ms 1116 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 5 ms 1624 KB Output is correct
44 Correct 4 ms 1372 KB Output is correct
45 Correct 2 ms 1056 KB Output is correct
46 Correct 2 ms 856 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 4 ms 1116 KB Output is correct
49 Correct 2 ms 600 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 4 ms 1116 KB Output is correct
53 Correct 4 ms 856 KB Output is correct
54 Correct 1 ms 604 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 6 ms 1408 KB Output is correct
57 Correct 3 ms 860 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
59 Correct 1 ms 604 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 4 ms 1112 KB Output is correct
63 Correct 3 ms 856 KB Output is correct
64 Correct 1 ms 604 KB Output is correct
65 Correct 1 ms 600 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 0 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 2 ms 860 KB Output is correct
73 Correct 3 ms 604 KB Output is correct
74 Correct 1 ms 604 KB Output is correct
75 Correct 1 ms 604 KB Output is correct
76 Correct 0 ms 360 KB Output is correct
77 Correct 4 ms 1372 KB Output is correct
78 Correct 3 ms 1116 KB Output is correct
79 Correct 2 ms 860 KB Output is correct
80 Correct 1 ms 604 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 4 ms 1116 KB Output is correct
83 Correct 3 ms 860 KB Output is correct
84 Correct 1 ms 348 KB Output is correct
85 Correct 0 ms 348 KB Output is correct
86 Correct 4 ms 1228 KB Output is correct
87 Correct 1 ms 604 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 10 ms 3220 KB Output is correct
90 Correct 6 ms 2140 KB Output is correct
91 Correct 5 ms 1628 KB Output is correct
92 Correct 0 ms 348 KB Output is correct
93 Correct 10 ms 3272 KB Output is correct
94 Correct 4 ms 1880 KB Output is correct
95 Correct 0 ms 348 KB Output is correct
96 Correct 19 ms 5472 KB Output is correct
97 Correct 13 ms 4188 KB Output is correct
98 Correct 8 ms 2908 KB Output is correct
99 Correct 5 ms 2396 KB Output is correct
100 Correct 0 ms 348 KB Output is correct
101 Correct 0 ms 348 KB Output is correct
102 Correct 0 ms 344 KB Output is correct
103 Correct 21 ms 5468 KB Output is correct
104 Correct 0 ms 348 KB Output is correct
105 Correct 2 ms 860 KB Output is correct
106 Correct 4 ms 1340 KB Output is correct
107 Correct 4 ms 1112 KB Output is correct
108 Correct 6 ms 1116 KB Output is correct
109 Correct 10 ms 3164 KB Output is correct
110 Correct 10 ms 3280 KB Output is correct
111 Correct 19 ms 5468 KB Output is correct
112 Correct 0 ms 344 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 12 ms 4188 KB Output is correct
115 Correct 0 ms 344 KB Output is correct
116 Correct 4 ms 1112 KB Output is correct
117 Correct 3 ms 1372 KB Output is correct
118 Correct 8 ms 2652 KB Output is correct
119 Correct 8 ms 2904 KB Output is correct
120 Correct 9 ms 2908 KB Output is correct
121 Correct 8 ms 2908 KB Output is correct
122 Correct 8 ms 2908 KB Output is correct
123 Correct 22 ms 5464 KB Output is correct
124 Correct 13 ms 4184 KB Output is correct
125 Correct 10 ms 2904 KB Output is correct
126 Correct 9 ms 2908 KB Output is correct
127 Correct 5 ms 2388 KB Output is correct
128 Correct 0 ms 344 KB Output is correct