Submission #281646

# Submission time Handle Problem Language Result Execution time Memory
281646 2020-08-23T09:33:31 Z NONAME Vision Program (IOI19_vision) C++14
0 / 100
12 ms 1152 KB
#include "vision.h"

void construct_network(int H, int W, int K) {
    std::vector <int> res, res1;

    if (K == 1) {
        std::vector <int> row, col;
        for (int i = 0; i < H; ++i) {
            std::vector <int> cur;
            for (int j = 0; j < W; ++j)
                cur.push_back(i * W + j);

            int x = add_or(cur);
            row.push_back(x);
        }

        for (int j = 0; j < W; ++j) {
            std::vector <int> cur;
            for (int i = 0; i < H; ++i)
                cur.push_back(i * W + j);

            int x = add_or(cur);
            col.push_back(x);
        }

        int rs1 = row[0];
        for (int i = 0; i < H - 1; ++i)
            rs1 = add_or({rs1, add_and({row[i], row[i + 1]})});

        int rs2 = col[0];
        for (int i = 0; i < W - 1; ++i)
            rs2 = add_or({rs2, add_and({col[i], col[i + 1]})});

        int total = add_and({rs1, rs2});

        int result = row[0];
        for (int i = 1; i < H; ++i)
            result = add_xor({result, row[i]});

        for (int i = 0; i < W; ++i)
            result = add_xor({(result == -1) ? col[i] : result, col[i]});

        add_and({total, result});

        return;
    }

    if (((H > 30) || (W > 30)) && (H > 1) && (W > 1)) {
        for (int x = 0; x < H; ++x)
        for (int y = 0; y < W; ++y) {
            if (x + y != K)
                continue;
            
            res.push_back(x * W + y);
        }

        add_or(res);
        add_and({0, H * W});
    } else {
        int cnt = 0;
        for (int x1 = 0; x1 < H; ++x1)
        for (int y1 = 0; y1 < W; ++y1) {
            std::vector <int> cur;

            for (int x2 = 0; x2 < H; ++x2)
            for (int y2 = 0; y2 < W; ++y2) {
                if ((abs(x1 - x2) + abs(y1 - y2)) != K)
                    continue;

                cur.push_back(x2 * W + y2);
            }

            if (cur.empty())
                continue;

            add_or(cur);
            res.push_back(H * W + cnt);
            ++cnt;
            add_and({x1 * W + y1, res.back()});
            res1.push_back(H * W + cnt);
            ++cnt;
        }

        add_or(res1);
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 2 ms 384 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1152 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 Incorrect 0 ms 256 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -