Submission #521744

# Submission time Handle Problem Language Result Execution time Memory
521744 2022-02-02T23:21:57 Z tabr Vision Program (IOI19_vision) C++17
32 / 100
4 ms 1356 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

#ifdef tabr
function<int(int)> add_not;
function<int(vector<int>)> add_and;
function<int(vector<int>)> add_or;
function<int(vector<int>)> add_xor;
#else
#include "vision.h"
#endif

void construct_network(int h, int w, int k) {
    vector<int> xs(h);
    for (int i = 0; i < h; i++) {
        vector<int> ask;
        for (int j = 0; j < w; j++) {
            ask.emplace_back(i * w + j);
        }
        xs[i] = add_or(ask);
    }
    vector<int> ys(w);
    for (int j = 0; j < w; j++) {
        vector<int> ask;
        for (int i = 0; i < h; i++) {
            ask.emplace_back(i * w + j);
        }
        ys[j] = add_or(ask);
    }
    vector<vector<int>> xt(h);
    xt[0].emplace_back(add_xor(xs));
    for (int i = 0; i < h; i++) {
        for (int j = i + 1; j < h; j++) {
            xt[j - i].emplace_back(add_and({xs[i], xs[j]}));
        }
    }
    vector<vector<int>> yt(w);
    yt[0].emplace_back(add_xor(ys));
    for (int i = 0; i < w; i++) {
        for (int j = i + 1; j < w; j++) {
            yt[j - i].emplace_back(add_and({ys[i], ys[j]}));
        }
    }
    vector<int> xu(h);
    for (int i = 0; i < h; i++) {
        xu[i] = add_or(xt[i]);
    }
    vector<int> yu(w);
    for (int i = 0; i < w; i++) {
        yu[i] = add_or(yt[i]);
    }
    vector<int> z;
    for (int i = 0; i < h; i++) {
        int j = k - i;
        if (j < 0 || w <= j) {
            continue;
        }
        z.emplace_back(add_and({xu[i], yu[j]}));
    }
    add_or(z);
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for (int h = 1; h <= 3; h++) {
        for (int w = 1; w <= 3; w++) {
            for (int k = 1; k <= h + w - 2; k++) {
                for (int z1 = 0; z1 < h * w; z1++) {
                    for (int z2 = z1 + 1; z2 < h * w; z2++) {
                        int x1 = z1 / w;
                        int y1 = z1 % w;
                        int x2 = z2 / w;
                        int y2 = z2 % w;
                        vector<int> data(h * w);
                        data[x1 * w + y1] = 1;
                        data[x2 * w + y2] = 1;
                        int cnt1 = 0;
                        int cnt2 = 0;
                        auto get = [&](int id) {
                            assert(0 <= id && id < (int) data.size());
                            assert(cnt2++ < 1000000);
                            return data[id];
                        };
                        auto add = [&](int v) {
                            assert(cnt1++ < 1000000);
                            data.emplace_back(v);
                        };
                        add_not = [&](int n) {
                            add(!get(n));
                            return (int) data.size() - 1;
                        };
                        add_and = [&](vector<int> ns) {
                            int res = 1;
                            for (int n : ns) {
                                res &= get(n);
                            }
                            add(res);
                            return (int) data.size() - 1;
                        };
                        add_or = [&](vector<int> ns) {
                            int res = 0;
                            for (int n : ns) {
                                res |= get(n);
                            }
                            add(res);
                            return (int) data.size() - 1;
                        };
                        add_xor = [&](vector<int> ns) {
                            int res = 0;
                            for (int n : ns) {
                                res ^= get(n);
                            }
                            add(res);
                            return (int) data.size() - 1;
                        };
                        construct_network(h, w, k);
                        if (data.back() != (k == abs(x1 - x2) + abs(y1 - y2))) {
                            cout << x1 << " " << x2 << " " << y1 << " " << y2 << '\n';
                            cout << data.back() << '\n';
                            cout << (k == abs(x1 - x2) + abs(y1 - y2)) << '\n';
                        }
                    }
                }
            }
        }
    }
    return 0;
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 288 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 288 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 272 KB Output is correct
22 Correct 1 ms 288 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 288 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 272 KB Output is correct
22 Correct 1 ms 288 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 292 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 292 KB Output is correct
34 Correct 1 ms 284 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 292 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 288 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 272 KB Output is correct
22 Correct 1 ms 288 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 292 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 292 KB Output is correct
34 Correct 1 ms 284 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 292 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Incorrect 2 ms 1096 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1096 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 800 KB Output is correct
4 Correct 4 ms 840 KB Output is correct
5 Correct 4 ms 832 KB Output is correct
6 Correct 4 ms 840 KB Output is correct
7 Correct 4 ms 840 KB Output is correct
8 Incorrect 2 ms 1100 KB WA in grader: Too many instructions
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1356 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 288 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 272 KB Output is correct
22 Correct 1 ms 288 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 292 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 292 KB Output is correct
34 Correct 1 ms 284 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 292 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Incorrect 2 ms 1096 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -