Submission #412856

# Submission time Handle Problem Language Result Execution time Memory
412856 2021-05-27T17:17:54 Z timmyfeng Vision Program (IOI19_vision) C++17
20 / 100
40 ms 3648 KB
#include <bits/stdc++.h>
using namespace std;

#include "vision.h"

const int L = 9;

int zero;

vector<int> dist(vector<int> cells) {
    int n = cells.size();

    vector<int> split(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        vector<int> l, r;
        for (int j = 0; j < n; ++j) {
            (j <= i ? l : r).push_back(cells[j]);
        }
        split[i] = add_and({add_or(l), add_or(r)});
    }

    vector<int> l(L, zero);
    for (int i = 0; i < L; ++i) {
        vector<int> ones, bools;
        for (int j = 0; j < n - 1; ++j) {
            if ((j & (1 << i)) > 0) {
                ones.push_back(cells[j]);
            }
            if (!ones.empty()) {
                bools.push_back(add_and({add_or(ones), split[j]}));
            }
        }
        if (!bools.empty()) {
            l[i] = add_or(bools);
        }
    }

    vector<int> r(L, zero);
    for (int i = 0; i < L; ++i) {
        vector<int> ones;
        for (int j = 0; j < n; ++j) {
            if ((j & (1 << i)) > 0) {
                ones.push_back(cells[j]);
            }
        }
        ones.push_back(l[i]);
        r[i] = add_xor(ones);
    }

    vector<int> diff(L);
    int carry = zero;

    for (int i = 0; i < L; ++i) {
        diff[i] = add_xor({l[i], r[i], carry});
        carry = add_or({add_and({l[i], r[i], carry}), add_and({add_not(r[i]), add_or({l[i], carry})})});
    }

    return diff;
}

void construct_network(int h, int w, int k) {
    zero = add_and({0, add_not(0)});

    vector<int> rows(h);
    for (int i = 0; i < h; ++i) {
        vector<int> row;
        for (int j = 0; j < w; ++j) {
            row.push_back(i * w + j);
        }
        rows[i] = add_or(row);
    }

    vector<int> cols(w);
    for (int i = 0; i < w; ++i) {
        vector<int> col;
        for (int j = 0; j < h; ++j) {
            col.push_back(j * w + i);
        }
        cols[i] = add_or(col);
    }

    vector<int> r = dist(rows), c = dist(cols), sum(L);
    int carry = zero;

    for (int i = 0; i < L; ++i) {
        sum[i] = add_xor({r[i], c[i], carry});
        carry = add_or({add_and({r[i], c[i]}), add_and({r[i], carry}), add_and({c[i], carry})});
    }

    for (int i = 0; i < L; ++i) {
        if ((k & (1 << i)) == 0) {
            sum[i] = add_not(sum[i]);
        }
    }

    add_and(sum);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1448 KB Output is correct
2 Correct 14 ms 1372 KB Output is correct
3 Correct 17 ms 1328 KB Output is correct
4 Correct 14 ms 1396 KB Output is correct
5 Correct 17 ms 1408 KB Output is correct
6 Correct 15 ms 1356 KB Output is correct
7 Correct 15 ms 1360 KB Output is correct
8 Correct 14 ms 1356 KB Output is correct
9 Correct 14 ms 1416 KB Output is correct
10 Correct 14 ms 1348 KB Output is correct
11 Correct 15 ms 1484 KB Output is correct
12 Correct 14 ms 1392 KB Output is correct
13 Correct 14 ms 1344 KB Output is correct
14 Correct 14 ms 1304 KB Output is correct
15 Correct 14 ms 1356 KB Output is correct
16 Correct 14 ms 1316 KB Output is correct
17 Correct 14 ms 1356 KB Output is correct
18 Correct 14 ms 1356 KB Output is correct
19 Correct 17 ms 1356 KB Output is correct
20 Correct 21 ms 1356 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 5 ms 716 KB Output is correct
4 Correct 8 ms 716 KB Output is correct
5 Correct 8 ms 716 KB Output is correct
6 Correct 6 ms 716 KB Output is correct
7 Correct 6 ms 760 KB Output is correct
8 Correct 9 ms 952 KB Output is correct
9 Correct 9 ms 972 KB Output is correct
10 Correct 9 ms 972 KB Output is correct
11 Correct 9 ms 972 KB Output is correct
12 Correct 9 ms 972 KB Output is correct
13 Correct 14 ms 1344 KB Output is correct
14 Correct 14 ms 1356 KB Output is correct
15 Correct 17 ms 1340 KB Output is correct
16 Correct 18 ms 1356 KB Output is correct
17 Correct 14 ms 1344 KB Output is correct
18 Correct 14 ms 1312 KB Output is correct
19 Correct 14 ms 1356 KB Output is correct
20 Correct 22 ms 2296 KB Output is correct
21 Correct 23 ms 2308 KB Output is correct
22 Correct 22 ms 2316 KB Output is correct
23 Correct 23 ms 2276 KB Output is correct
24 Correct 22 ms 2248 KB Output is correct
25 Correct 22 ms 2312 KB Output is correct
26 Correct 22 ms 2228 KB Output is correct
27 Correct 39 ms 3648 KB Output is correct
28 Correct 38 ms 3608 KB Output is correct
29 Correct 37 ms 3632 KB Output is correct
30 Correct 40 ms 3632 KB Output is correct
31 Correct 39 ms 3592 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 3648 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB on inputs (0, 1), (1, 1), expected 1, but computed 0
6 Halted 0 ms 0 KB -