Submission #602715

#TimeUsernameProblemLanguageResultExecution timeMemory
602715JohannVision Program (IOI19_vision)C++14
59 / 100
35 ms4240 KiB
#include "vision.h"

using namespace std;

typedef vector<int> vi;
#define sz(x) (int)(x).size()

int h, w, k;

struct diag {
    int D;
    vi P;
    int OR;
    int TWO;
};

int calc_pos(int x, int y) {
    return y * w + x;
}

int check_auf_zwei_Punkte(vi & q, int pos_or) {
    return add_and({ pos_or, add_not(add_xor(q)) });
}
int check_diag(vector<diag> & D, int i, int K) {
    vi qor, qtwo;
    for (int j = 0; j < K; ++j) {
        qor.push_back(D[i + j].OR);
        qtwo.push_back(D[i + j].TWO);
    }
    qtwo.push_back(add_and({add_or(qor), add_not(add_xor(qor))}));
    return add_or(qtwo);
}

void construct_network(int H, int W, int K) {
    h = H;
    w = W;
    k = K;
    // Rechte Diagonalen (x - y = konst)
    vector<diag> R;
    for (int d = -H+1; d < W; ++d) {
        R.push_back(diag());
        R.back().D = d;
        for (int x = 0; x < W; ++x) {
            int y = x - d;
            if (0 <= y && y < H) {
                R.back().P.push_back(calc_pos(x,y));
            }
        }
        R.back().OR = add_or(R.back().P);
        R.back().TWO = check_auf_zwei_Punkte(R.back().P, R.back().OR);
    }
    // Linke Diagonale (x + y = konst)
    vector<diag> L;
    for (int d = 0; d <= H + W - 2; ++d) {
        L.push_back(diag());
        L.back().D = d;
        for (int x = 0; x < W; ++x) {
            int y = d - x;
            if (0 <= y && y < H) {
                L.back().P.push_back(calc_pos(x,y));
            }
        }
        L.back().OR = add_or(L.back().P);
        L.back().TWO = check_auf_zwei_Punkte(L.back().P, L.back().OR);
    }
    // Blöcke mit Größe K enthält zwei dinger...
    vi RK, LK;
    for (int i = 0; i <= sz(R)-K; ++i) {
        RK.push_back(check_diag(R, i, K));
        LK.push_back(check_diag(L, i, K));
    }
    int tRK = add_or(RK);
    int tLK = add_or(LK);
    int kb = add_and({ tRK, tLK });
    int nkb = add_not(kb);
    // Blöcke mit K+1 enthält zwei dinger
    vi RK1, LK1;
    for (int i = 0; i <= sz(R)-K-1; ++i) {
        RK1.push_back(check_diag(R, i, K+1));
        LK1.push_back(check_diag(L, i, K+1));
    }
    int tRK1 = add_or(RK1);
    int tLK1 = add_or(LK1);
    int kb1 = add_and({ tRK1, tLK1 });

    int ans = add_and({ kb1, nkb });
}

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:86:9: warning: unused variable 'ans' [-Wunused-variable]
   86 |     int ans = add_and({ kb1, nkb });
      |         ^~~
#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...