Submission #617790

# Submission time Handle Problem Language Result Execution time Memory
617790 2022-08-01T14:22:58 Z lorenzoferrari Vision Program (IOI19_vision) C++17
12 / 100
8 ms 1128 KB
#include "vision.h"
#include <vector>
#include <cassert>
using namespace std;

void subtask5(int h, int w, int k) {
    int l = h*w;
    int r = l;
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
        for (int ii = i; ii < h; ++ii) for (int jj = 0; jj < w; ++jj) {
            if (abs(i-ii) + abs(j-jj) != k) continue;
            vector<int> q;
            q.push_back(i*w + j);
            q.push_back(ii*w + jj);
            r = add_and(q);
        }
    }
    vector<int> q;
    for (int i = l; i <= r; ++i) {
        q.push_back(i);
    }
    add_or(q);
}

void subtask6(int h, int w, int k) {
    // 0,0 is black
    vector<int> tor;
    for (int i = 0; i <= k; ++i) {
        int j = k - i;
        if (!(0 <= i && i < h)) continue;
        if (!(0 <= j && j < w)) continue;
        tor.push_back(add_and({0, i*w+j}));
    }
    add_or(tor);
}

void construct_network(int h, int w, int k) {
    if (min(h, w) == 1) {
        subtask5(h, w, k);
        return;
    }
    /*else if (max(h, w) > 30) {
        subtask6(h, w, k);
        return;
    }*/
    int tid = add_or({0, add_not(0)});
    int fid = add_not(tid);
    vector<int> rows(h);
    vector<int> cols(w);
    for (int i = 0; i < h; ++i) {
        vector<int> q;
        for (int j = 0; j < w; ++j) {
            q.push_back(i*w + j);
        }
        rows[i] = add_or(q);
    }
    for (int j = 0; j < w; ++j) {
        vector<int> q;
        for (int i = 0; i < h; ++i) {
            q.push_back(i*w + j);
        }
        cols[j] = add_or(q);
    }

    auto add_fixed = [&](vector<int> v, int d) -> int {
        assert(0 < d && d < (int)v.size());
        vector<int> tor;
        for (int i = 0; i + d < (int)v.size(); ++i) {
            tor.push_back(add_and({v[i], v[i+d]}));
        }
        return add_or(tor);
    };

    vector<int> dh(h, fid);
    vector<int> dw(w, fid);
    for (int i = 1; i < h && i <= k; ++i) dh[i] = add_fixed(rows, i);
    for (int i = 1; i < w && i <= k; ++i) dw[i] = add_fixed(cols, i);

    vector<int> nh(1,tid);
    vector<int> nw(1,tid);
    for (int i = 1; i < h; ++i) nh.push_back(add_not(dh[i]));
    for (int i = 1; i < w; ++i) nw.push_back(add_not(dw[i]));
    dh[0] = add_and(nh);
    dw[0] = add_and(nw);

    vector<int> tor(1, fid);
    for (int i = 0; i < h; ++i) {
        int j = k - i;
        if (0 <= j && j < w) {
            tor.push_back(add_and({dh[i], dw[j]}));
        }
    }

    add_or(tor);
}
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 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 1 ms 340 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 4 ms 720 KB Output is correct
6 Correct 5 ms 812 KB Output is correct
7 Correct 4 ms 720 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 7 ms 1124 KB Output is correct
11 Incorrect 1 ms 1104 KB WA in grader: Too many instructions
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1128 KB on inputs (57, 107), (59, 108), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 0 ms 212 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
8 Halted 0 ms 0 KB -