Submission #1350848

#TimeUsernameProblemLanguageResultExecution timeMemory
1350848Desh03Vision Program (IOI19_vision)C++20
0 / 100
1 ms1348 KiB
#include "vision.h"
#include <bits/stdc++.h>

using namespace std;

void construct_network(int h, int w, int k) {
    vector<int> col(w), row(h), v;
    for (int i = 0; i < h; i++) {
        v.clear();
        for (int j = 0; j < w; j++) {
            v.push_back(w * i + j);
        }
        row[i] = add_or(v);
    }
    for (int j = 0; j < w; j++) {
        vector<int> v;
        for (int i = 0; i < h; i++) {
            v.push_back(w * i + j);
        }
        col[j] = add_or(v);
    }
    vector<int> x(w), y(h);
    vector<int> vv;
    for (int i = 0; i < h; i++) {
        v.clear();
        for (int j = 0; j < w; j++) {
            v.push_back(w * i + j);
        }
        vv.push_back(add_xor(v));
    }
    y[0] = add_not(add_or(vv));
    vv.clear();
    for (int j = 0; j < w; j++) {
        v.clear();
        for (int i = 0; i < h; i++) {
            v.push_back(w * i + j);
        }
        vv.push_back(add_xor(v));
    }
    x[0] = add_not(add_or(vv));
    int suf;
    for (int dx = w - 1; dx > 0; dx--) {
        if (dx == w - 1) {
            x[dx] = suf = add_and({col[0], col[w - 1]});
            continue;
        }
        vector<int> v1, v2;
        for (int j = 0; j < w; j++) {
            if ((j / dx) & 1) v1.push_back(col[j]);
            else if (j + dx < w || j >= dx) v2.push_back(col[j]);
        }
        x[dx] = add_and({add_or(v1), add_or(v2), add_not(suf)});
        suf = add_or({suf, x[dx]});
    }
    for (int dy = h - 1; dy > 0; dy--) {
        if (dy == h - 1) {
            y[dy] = suf = add_and({row[0], row[h - 1]});
            continue;
        }
        vector<int> v1, v2;
        for (int j = 0; j < h; j++) {
            if ((j / dy) & 1) v1.push_back(row[j]);
            else if (j + dy < h || j >= dy) v2.push_back(row[j]);
        }
        y[dy] = add_and({add_or(v1), add_or(v2), add_not(suf)});
        suf = add_or({suf, y[dy]});
    }
    v.clear();
    for (int i = k - h + 1; i <= min(w - 1, k); i++) {
        v.push_back(add_and({x[i], y[k - i]}));
    }
    add_or(v);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...