답안 #797491

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
797491 2023-07-29T12:54:32 Z HaroldVemeno Vision Program (IOI19_vision) C++17
100 / 100
12 ms 1652 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(10);
        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, zero);
        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(10);
        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, zero);
        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);
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 296 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 296 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 296 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 3 ms 680 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 428 KB Output is correct
43 Correct 3 ms 684 KB Output is correct
44 Correct 3 ms 596 KB Output is correct
45 Correct 3 ms 596 KB Output is correct
46 Correct 6 ms 596 KB Output is correct
47 Correct 3 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 3 ms 468 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 3 ms 560 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 2 ms 556 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 548 KB Output is correct
18 Correct 3 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 3 ms 560 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 552 KB Output is correct
13 Correct 3 ms 560 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 3 ms 556 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 468 KB Output is correct
18 Correct 3 ms 468 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 7 ms 1068 KB Output is correct
21 Correct 7 ms 980 KB Output is correct
22 Correct 7 ms 984 KB Output is correct
23 Correct 7 ms 980 KB Output is correct
24 Correct 7 ms 980 KB Output is correct
25 Correct 7 ms 980 KB Output is correct
26 Correct 6 ms 980 KB Output is correct
27 Correct 11 ms 1552 KB Output is correct
28 Correct 12 ms 1548 KB Output is correct
29 Correct 11 ms 1636 KB Output is correct
30 Correct 11 ms 1580 KB Output is correct
31 Correct 11 ms 1576 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1628 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 6 ms 980 KB Output is correct
8 Correct 6 ms 1068 KB Output is correct
9 Correct 12 ms 1616 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 296 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 3 ms 680 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 428 KB Output is correct
43 Correct 3 ms 684 KB Output is correct
44 Correct 3 ms 596 KB Output is correct
45 Correct 3 ms 596 KB Output is correct
46 Correct 6 ms 596 KB Output is correct
47 Correct 3 ms 596 KB Output is correct
48 Correct 3 ms 468 KB Output is correct
49 Correct 3 ms 468 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 3 ms 468 KB Output is correct
52 Correct 3 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 3 ms 552 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 3 ms 468 KB Output is correct
57 Correct 3 ms 560 KB Output is correct
58 Correct 2 ms 468 KB Output is correct
59 Correct 3 ms 468 KB Output is correct
60 Correct 2 ms 556 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 3 ms 596 KB Output is correct
63 Correct 3 ms 468 KB Output is correct
64 Correct 3 ms 548 KB Output is correct
65 Correct 3 ms 468 KB Output is correct
66 Correct 2 ms 468 KB Output is correct
67 Correct 3 ms 560 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 1 ms 300 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 2 ms 428 KB Output is correct
74 Correct 2 ms 468 KB Output is correct
75 Correct 2 ms 468 KB Output is correct
76 Correct 2 ms 468 KB Output is correct
77 Correct 3 ms 596 KB Output is correct
78 Correct 3 ms 596 KB Output is correct
79 Correct 3 ms 596 KB Output is correct
80 Correct 3 ms 596 KB Output is correct
81 Correct 3 ms 552 KB Output is correct
82 Correct 3 ms 560 KB Output is correct
83 Correct 2 ms 468 KB Output is correct
84 Correct 3 ms 556 KB Output is correct
85 Correct 3 ms 468 KB Output is correct
86 Correct 3 ms 468 KB Output is correct
87 Correct 3 ms 468 KB Output is correct
88 Correct 3 ms 468 KB Output is correct
89 Correct 7 ms 1068 KB Output is correct
90 Correct 7 ms 980 KB Output is correct
91 Correct 7 ms 984 KB Output is correct
92 Correct 7 ms 980 KB Output is correct
93 Correct 7 ms 980 KB Output is correct
94 Correct 7 ms 980 KB Output is correct
95 Correct 6 ms 980 KB Output is correct
96 Correct 11 ms 1552 KB Output is correct
97 Correct 12 ms 1548 KB Output is correct
98 Correct 11 ms 1636 KB Output is correct
99 Correct 11 ms 1580 KB Output is correct
100 Correct 11 ms 1576 KB Output is correct
101 Correct 1 ms 340 KB Output is correct
102 Correct 1 ms 340 KB Output is correct
103 Correct 11 ms 1628 KB Output is correct
104 Correct 1 ms 340 KB Output is correct
105 Correct 2 ms 424 KB Output is correct
106 Correct 3 ms 596 KB Output is correct
107 Correct 3 ms 556 KB Output is correct
108 Correct 3 ms 596 KB Output is correct
109 Correct 6 ms 980 KB Output is correct
110 Correct 6 ms 1068 KB Output is correct
111 Correct 12 ms 1616 KB Output is correct
112 Correct 1 ms 296 KB Output is correct
113 Correct 1 ms 340 KB Output is correct
114 Correct 11 ms 1620 KB Output is correct
115 Correct 3 ms 468 KB Output is correct
116 Correct 2 ms 556 KB Output is correct
117 Correct 6 ms 980 KB Output is correct
118 Correct 6 ms 1068 KB Output is correct
119 Correct 11 ms 1596 KB Output is correct
120 Correct 11 ms 1580 KB Output is correct
121 Correct 11 ms 1620 KB Output is correct
122 Correct 11 ms 1612 KB Output is correct
123 Correct 11 ms 1620 KB Output is correct
124 Correct 11 ms 1636 KB Output is correct
125 Correct 11 ms 1580 KB Output is correct
126 Correct 11 ms 1620 KB Output is correct
127 Correct 11 ms 1576 KB Output is correct
128 Correct 11 ms 1652 KB Output is correct