Submission #797471

# Submission time Handle Problem Language Result Execution time Memory
797471 2023-07-29T12:38:33 Z HaroldVemeno Vision Program (IOI19_vision) C++17
0 / 100
11 ms 2348 KB
#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> dr(10);
    vector<int> dc(10);
    {
        vector<int> nors(H);
        vector<int> sam;
        for(int i = 0; i < H; ++i) {
            sam.push_back(rows[i]);
            nors[i] = add_not(add_or(sam));
        }
        vector<int> d1(1);
        for(int d = 0; d < 10; ++d) {
            vector<int> s{zero};
            for(int i = (1 << d) - 1; i < H; i += 1 << d) {
                s.push_back(nors[i]);
            }
            d1[d] = add_xor(s);
        }
        vector<int> d2(10);
        for(int d = 0; d < 10; ++d) {
            vector<int> e{zero};
            vector<int> o{zero};
            for(int i = 0; i < H; ++i) {
                if(i & (1 << d)) e.push_back(rows[i]);
                else o.push_back(rows[i]);
            }
            int eor = add_or(e);
            int oor = add_or(o);
            d2[d] = add_xor({d1[d], add_and({eor, oor})});
        }
        vector<int> d2i(10);
        for(int d = 0; d < 9; ++d) {
            d2i[d] = add_not(d2[d]);
        }
        vector<int> cr(11, zero);
        for(int d = 0; d < 10; ++d) {
            auto p = add3(d1[d], d2i[d], cr[d]);
            dr[d] = p.first;
            cr[d+1] = p.second;
        }
    }
    {
        vector<int> nors(W);
        vector<int> sam;
        for(int i = 0; i < W; ++i) {
            sam.push_back(cols[i]);
            nors[i] = add_not(add_or(sam));
        }
        vector<int> d1(1);
        for(int d = 0; d < 10; ++d) {
            vector<int> s{zero};
            for(int i = (1 << d) - 1; i < W; i += 1 << d) {
                s.push_back(nors[i]);
            }
            d1[d] = add_xor(s);
        }
        vector<int> d2(10);
        for(int d = 0; d < 10; ++d) {
            vector<int> e{zero};
            vector<int> o{zero};
            for(int i = 0; i < W; ++i) {
                if(i & (1 << d)) e.push_back(cols[i]);
                else o.push_back(cols[i]);
            }
            int eor = add_or(e);
            int oor = add_or(o);
            d2[d] = add_xor({d1[d], add_and({eor, oor})});
        }
        vector<int> d2i(10);
        for(int d = 0; d < 9; ++d) {
            d2i[d] = add_not(d2[d]);
        }
        vector<int> cr(11, zero);
        for(int d = 0; d < 10; ++d) {
            auto p = add3(d1[d], d2i[d], cr[d]);
            dc[d] = p.first;
            cr[d+1] = p.second;
        }
    }
    vector<int> cr(11, zero);
    vector<int> fd(10);
    for(int d = 0; d < 10; ++d) {
        auto p = add3(dr[d], dc[d], cr[d]);
        fd[d] = p.first;
        cr[d+1] = p.second;
    }

    vector<int> cd(10);

    for(int d = 0; d < 10; ++d) {
        if((1022 - K) & (1 << d)) {
            cd[d] = fd[d];
        } else {
            cd[d] = add_not(fd[d]);
        }
    }

    add_and(cd);
}

Compilation message

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 time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 852 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 2348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -