Submission #362630

# Submission time Handle Problem Language Result Execution time Memory
362630 2021-02-03T18:37:35 Z mihai145 Vision Program (IOI19_vision) C++14
0 / 100
3 ms 1516 KB
#include "vision.h"
#include <vector>
#include <cassert>

using namespace std;

int _H, _W;

int Get_Index(int x, int y) {
    return x * _W + y;
}

void construct_network(int H, int W, int K) {

    _H = H;
    _W = W;

    vector<int> diag[2][H + W - 2];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            diag[0][i + j].push_back(Get_Index(i, j));
            diag[1][i - j + W - 1].push_back(Get_Index(i, j));
        }
    }

    int diagOR[2][H + W - 1];
    int diagPref[2][H + W - 1], diagSuf[2][H + W - 1];
    int diagEq[2], diagLEQ[2];

    for (int d : {0, 1}) {
        for (int i = 0; i < H + W - 1; i++) {
            diagOR[d][i] = add_or(diag[d][i]);
        }

        diagPref[d][0] = diagOR[d][0];
        for (int i = 1; i < H + W - 1; i++) {
            diagPref[d][i] = add_or({diagPref[d][i - 1], diagOR[d][i]});
        }

        diagSuf[d][H + W - 2] = diagOR[d][H + W - 2];
        for (int i = H + W - 3; i >= 0; i--) {
            diagSuf[d][i] = add_or({diagSuf[d][i + 1], diagOR[d][i]});
        }

        vector<int> tmp;
        for (int i = 0; i + K < H + W - 1; i++) {
            tmp.push_back(add_and({diagOR[d][i], diagOR[d][i + K]}));
        }
        diagEq[d] = add_or(tmp);

        tmp.clear();
        if (W + H - 1 > K + 1) {
            tmp.push_back(diagPref[d][H + W - 3 - K]);
            tmp.push_back(diagSuf[d][K + 1]);
        }

        for (int i = 1; i + K + 1 < W + H - 1; i++) {
            tmp.push_back(add_or({diagPref[d][i - 1], diagSuf[d][i + K + 1]}));
        }

        if (tmp.empty()) {
            diagLEQ[d] = diagPref[d][W + H - 2];
        } else {
            diagLEQ[d] = add_not(add_and(tmp));
        }
        //tmp.clear();
    }

    add_or({
                   add_and({diagEq[0], diagLEQ[1]}),
                   add_and({diagEq[1], diagLEQ[0]})
           });

    /*
	std::vector<int> Ns;
	Ns = {0, 1};
	int a = add_and(Ns);
	Ns = {0, a};
	int b = add_or(Ns);
	Ns = {0, 1, b};
	int c = add_xor(Ns);
	add_not(c);
    */
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1516 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -