Submission #796949

#TimeUsernameProblemLanguageResultExecution timeMemory
796949HaroldVemenoVision Program (IOI19_vision)C++17
24 / 100
8 ms1400 KiB
#include "vision.h"

#include <bits/stdc++.h>

#ifdef GUDEB
    #define D(x) cerr << #x << ": " << (x) << '\n';
    #define ifdeb if(true)
#else
    #define D(x) ;
    #define ifdeb if(false)
#endif

#define all(x) begin(x), end(x)

using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;

pair<int, int> add3(int a, int b, int c) {
    int no = add_not(add_or({a, b, c}));
    int na = add_not(add_and({a, b, c}));
    int xr = add_xor({a, b, c});
    int cr = add_xor({na, no, xr});
    return {xr, cr};
}

void construct_network(int H, int W, int K) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int zero = add_xor({0, 0});
    int one = add_not(zero);

    vector<int> rows(H);
    vector<int> cols(W);

    for(int i = 0; i < H; ++i) {
        vector<int> row;
        for(int j = i*W; j < (i+1)*W; ++j) {
            row.push_back(j);
        }
        rows[i] = add_or(row);
    }
    for(int i = 0; i < W; ++i) {
        vector<int> col;
        for(int j = i; j < H*W; j += W) {
            col.push_back(j);
        }
        cols[i] = add_or(col);
    }
    vector<int> d1(10);
    for(int d = 0; d < 10; ++d) {
        vector<int> spcs;
        int l = 1 << d;
        for(int i = 0; i+l < H; ++i) {
            spcs.push_back(add_and({rows[i], rows[i+l]}));
        }
        spcs.push_back(zero);
        d1[d] = add_or(spcs);
    }
    vector<int> d2(10);
    for(int d = 0; d < 10; ++d) {
        vector<int> spcs;
        int l = 1 << d;
        for(int i = 0; i+l < W; ++i) {
            spcs.push_back(add_and({cols[i], cols[i+l]}));
        }
        spcs.push_back(zero);
        d2[d] = add_or(spcs);
    }
    vector<int> cr(11, zero);
    vector<int> d3(10);
    for(int d = 0; d < 10; ++d) {
        auto p = add3(d1[d], d2[d], cr[d]);
        d3[d] = p.first;
        cr[d+1] = p.second;
    }

    vector<int> fd3(10);

    for(int d = 0; d < 10; ++d) {
        if(K & (1 << d)) {
            fd3[d] = d3[d];
        } else {
            fd3[d] = add_not(d3[d]);
        }
    }

    add_and(fd3);
}

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:32:9: warning: unused variable 'one' [-Wunused-variable]
   32 |     int one = add_not(zero);
      |         ^~~
#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...