Submission #657863

#TimeUsernameProblemLanguageResultExecution timeMemory
657863benjaminkleynVision Program (IOI19_vision)C++17
12 / 100
34 ms4040 KiB
#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
typedef long long ll;

void construct_network(int h, int w, int k)
{
    vector<int> rd1(h + w - 1), rd2(h + w - 1);
    vector<int> ld1(h + w - 1), ld2(h + w - 1);
    for (int d = 0; d < h + w - 1; d++)
    {
        // right-diagonal of (i, j) = i + j
        vector<int> idx;
        for (int i = 0; i < h; i++)
            if (0 <= d - i && d - i < w)
                idx.push_back(i * w + d - i);
        // rd1 : is there at least one black pixel on this diagonal?
        rd1[d] = add_or(idx);
        // rd2 : are there exactly two black pixels on this diagonal?
        rd2[d] = add_xor({add_xor(idx), rd1[d]});

        // left-diagonal of (i, j) = i - j + (w - 1)
        idx.clear();
        for (int i = 0; i < h; i++)
            if (0 <= i - d + w - 1 && i - d + w - 1 < w)
                idx.push_back(i * w + i - d + w - 1);
        // ld1 : is there at least one black pixel on this diagonal?
        ld1[d] = add_or(idx);
        // ld2 : are there exactly two black pixels on this diagonal?
        ld2[d] = add_xor({add_xor(idx), rd1[d]});
    }
    vector<int> A, B, C, D;
    for (int d = 0; d + k < h + w - 1; d++)
    {
        vector<int> idxR1, idxR2, idxL1, idxL2;
        for (int i = 0; i < k + 1; i++)
        {
            idxR1.push_back(rd1[d + i]);
            idxR2.push_back(rd2[d + i]);
            idxL1.push_back(ld1[d + i]);
            idxL2.push_back(ld2[d + i]);
        }
        A.push_back(add_or({add_xor({add_or(idxR1), add_xor(idxR1)}),add_or(idxR2)}));
        B.push_back(add_or({add_xor({add_or(idxL1), add_xor(idxL1)}),add_or(idxL2)}));
    }

    for (int d = 0; d + k - 1 < h + w - 1; d++)
    {
        vector<int> idxR1, idxR2, idxL1, idxL2;
        for (int i = 0; i < k; i++)
        {
            idxR1.push_back(rd1[d + i]);
            idxR2.push_back(rd2[d + i]);
            idxL1.push_back(ld1[d + i]);
            idxL2.push_back(ld2[d + i]);
        }
        C.push_back(add_or({add_xor({add_or(idxR1), add_xor(idxR1)}),add_or(idxR2)}));
        D.push_back(add_or({add_xor({add_or(idxL1), add_xor(idxL1)}),add_or(idxL2)}));
    }
    int x = add_and({add_or(A), add_or(B)});
    int y = add_and({add_or(C), add_or(D)});

    add_and({x, add_not(y)});
}
#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...