답안 #294634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
294634 2020-09-09T07:45:35 Z 2qbingxuan Vision Program (IOI19_vision) C++14
100 / 100
27 ms 3068 KB
#include "vision.h"

#include <bits/stdc++.h>
#ifdef local
#define debug(args...) qqbx(#args, args)
template <typename H, typename ...T> void qqbx(const char *s, const H&h, T &&...args) {
    for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
    std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
    if constexpr(sizeof...(T)) qqbx(++s, args...);
}
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define pb emplace_back
#define all(v) begin(v),end(v)

using namespace std;

void construct_network(int H, int W, int k) {
    int tot = H * W;
    int zero = -1;
    {
        add_not(0);
        add_and({0, tot++});
        zero = tot++;
    }
    vector<vector<int>> id(H, vector<int>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            id[i][j] = i * W + j;
        }
    }
    vector<vector<int>> diagId(2, vector<int>(H+W, zero));
    vector<vector<int>> dId(2, vector<int>(H+W, zero));
    {
        vector<vector<vector<int>>> diag(2, vector<vector<int>>(H+W));
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                diag[0][i+j].pb(id[i][j]);
                diag[1][i-j+W-1].pb(id[i][j]);
            }
        }
        for(int c = 0; c < 2; c++) for(int i = 0; i < H+W; i++) {
            if(diag[c][i].size()) {
                add_xor(diag[c][i]);
                diagId[c][i] = tot++;
                add_or(diag[c][i]);
                dId[c][i] = tot++;
            }
        }
    }
    vector<vector<int>> preId(2, vector<int>(H+W, zero));
    vector<vector<int>> pId(2, vector<int>(H+W, zero));
    for(int c = 0; c < 2; c++) for(int i = 0; i < H+W; i++) {
        add_xor({i ? preId[c][i-1] : zero, diagId[c][i]});
        preId[c][i] = tot++;
        add_or({i ? pId[c][i-1] : zero, dId[c][i]});
        pId[c][i] = tot++;
    }
    vector<int> exactly[2], maybe[2];
    for(int c = 0; c < 2; c++) for(int i = 0; i+k < H+W; i++) {
        add_and({diagId[c][i], diagId[c][i+k]});
        exactly[c].pb(tot++);
    }
    for(int c = 0; c < 2; c++) for(int i = -k; i < H+W; i++) {
        int l = i <= 0 ? zero : preId[c][i-1];
        int r = preId[c][min(H+W-1, i+k)];
        add_xor({l, r});
        add_not(tot++);
        int x = tot++, y = pId[c][min(H+W-1, i+k)], z = i <= 0 ? zero : pId[c][i-1];
        add_not(z), z = tot++;
        add_and({x, y, z});
        maybe[c].pb(tot++);
    }
    add_or(exactly[0]);
    int a = tot++;
    add_or(maybe[1]);
    int b = tot++;
    add_and({a, b});
    int X = tot++;
    add_or(exactly[1]);
    int c = tot++;
    add_or(maybe[0]);
    int d = tot++;
    add_and({c, d});
    int Y = tot++;
    add_or({X, Y});
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 2 ms 512 KB Output is correct
38 Correct 7 ms 1184 KB Output is correct
39 Correct 2 ms 512 KB Output is correct
40 Correct 2 ms 512 KB Output is correct
41 Correct 5 ms 768 KB Output is correct
42 Correct 5 ms 896 KB Output is correct
43 Correct 7 ms 1152 KB Output is correct
44 Correct 7 ms 1152 KB Output is correct
45 Correct 11 ms 1148 KB Output is correct
46 Correct 8 ms 1148 KB Output is correct
47 Correct 9 ms 1148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 640 KB Output is correct
2 Correct 4 ms 752 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 4 ms 768 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 3 ms 768 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 5 ms 744 KB Output is correct
13 Correct 3 ms 800 KB Output is correct
14 Correct 3 ms 768 KB Output is correct
15 Correct 3 ms 640 KB Output is correct
16 Correct 4 ms 640 KB Output is correct
17 Correct 3 ms 768 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 3 ms 768 KB Output is correct
20 Correct 3 ms 768 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 640 KB Output is correct
4 Correct 3 ms 640 KB Output is correct
5 Correct 4 ms 640 KB Output is correct
6 Correct 4 ms 672 KB Output is correct
7 Correct 4 ms 768 KB Output is correct
8 Correct 5 ms 896 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 5 ms 896 KB Output is correct
11 Correct 6 ms 896 KB Output is correct
12 Correct 6 ms 896 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 3 ms 640 KB Output is correct
15 Correct 3 ms 768 KB Output is correct
16 Correct 3 ms 768 KB Output is correct
17 Correct 3 ms 640 KB Output is correct
18 Correct 3 ms 768 KB Output is correct
19 Correct 3 ms 768 KB Output is correct
20 Correct 13 ms 1920 KB Output is correct
21 Correct 13 ms 1920 KB Output is correct
22 Correct 14 ms 1920 KB Output is correct
23 Correct 14 ms 1920 KB Output is correct
24 Correct 13 ms 1920 KB Output is correct
25 Correct 14 ms 1920 KB Output is correct
26 Correct 16 ms 2048 KB Output is correct
27 Correct 24 ms 2944 KB Output is correct
28 Correct 24 ms 2936 KB Output is correct
29 Correct 24 ms 3068 KB Output is correct
30 Correct 25 ms 3060 KB Output is correct
31 Correct 25 ms 3060 KB Output is correct
32 Correct 1 ms 256 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2944 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 3 ms 640 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 3 ms 640 KB Output is correct
7 Correct 15 ms 1920 KB Output is correct
8 Correct 13 ms 1920 KB Output is correct
9 Correct 23 ms 2936 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 2 ms 512 KB Output is correct
38 Correct 7 ms 1184 KB Output is correct
39 Correct 2 ms 512 KB Output is correct
40 Correct 2 ms 512 KB Output is correct
41 Correct 5 ms 768 KB Output is correct
42 Correct 5 ms 896 KB Output is correct
43 Correct 7 ms 1152 KB Output is correct
44 Correct 7 ms 1152 KB Output is correct
45 Correct 11 ms 1148 KB Output is correct
46 Correct 8 ms 1148 KB Output is correct
47 Correct 9 ms 1148 KB Output is correct
48 Correct 3 ms 640 KB Output is correct
49 Correct 4 ms 752 KB Output is correct
50 Correct 3 ms 768 KB Output is correct
51 Correct 4 ms 768 KB Output is correct
52 Correct 3 ms 640 KB Output is correct
53 Correct 3 ms 640 KB Output is correct
54 Correct 3 ms 768 KB Output is correct
55 Correct 3 ms 768 KB Output is correct
56 Correct 3 ms 640 KB Output is correct
57 Correct 3 ms 640 KB Output is correct
58 Correct 5 ms 768 KB Output is correct
59 Correct 5 ms 744 KB Output is correct
60 Correct 3 ms 800 KB Output is correct
61 Correct 3 ms 768 KB Output is correct
62 Correct 3 ms 640 KB Output is correct
63 Correct 4 ms 640 KB Output is correct
64 Correct 3 ms 768 KB Output is correct
65 Correct 5 ms 768 KB Output is correct
66 Correct 3 ms 768 KB Output is correct
67 Correct 3 ms 768 KB Output is correct
68 Correct 1 ms 256 KB Output is correct
69 Correct 0 ms 256 KB Output is correct
70 Correct 0 ms 256 KB Output is correct
71 Correct 1 ms 256 KB Output is correct
72 Correct 3 ms 640 KB Output is correct
73 Correct 3 ms 640 KB Output is correct
74 Correct 4 ms 640 KB Output is correct
75 Correct 4 ms 672 KB Output is correct
76 Correct 4 ms 768 KB Output is correct
77 Correct 5 ms 896 KB Output is correct
78 Correct 5 ms 896 KB Output is correct
79 Correct 5 ms 896 KB Output is correct
80 Correct 6 ms 896 KB Output is correct
81 Correct 6 ms 896 KB Output is correct
82 Correct 3 ms 640 KB Output is correct
83 Correct 3 ms 640 KB Output is correct
84 Correct 3 ms 768 KB Output is correct
85 Correct 3 ms 768 KB Output is correct
86 Correct 3 ms 640 KB Output is correct
87 Correct 3 ms 768 KB Output is correct
88 Correct 3 ms 768 KB Output is correct
89 Correct 13 ms 1920 KB Output is correct
90 Correct 13 ms 1920 KB Output is correct
91 Correct 14 ms 1920 KB Output is correct
92 Correct 14 ms 1920 KB Output is correct
93 Correct 13 ms 1920 KB Output is correct
94 Correct 14 ms 1920 KB Output is correct
95 Correct 16 ms 2048 KB Output is correct
96 Correct 24 ms 2944 KB Output is correct
97 Correct 24 ms 2936 KB Output is correct
98 Correct 24 ms 3068 KB Output is correct
99 Correct 25 ms 3060 KB Output is correct
100 Correct 25 ms 3060 KB Output is correct
101 Correct 1 ms 256 KB Output is correct
102 Correct 1 ms 256 KB Output is correct
103 Correct 24 ms 2944 KB Output is correct
104 Correct 1 ms 384 KB Output is correct
105 Correct 3 ms 640 KB Output is correct
106 Correct 5 ms 896 KB Output is correct
107 Correct 3 ms 640 KB Output is correct
108 Correct 3 ms 640 KB Output is correct
109 Correct 15 ms 1920 KB Output is correct
110 Correct 13 ms 1920 KB Output is correct
111 Correct 23 ms 2936 KB Output is correct
112 Correct 1 ms 256 KB Output is correct
113 Correct 1 ms 256 KB Output is correct
114 Correct 24 ms 2944 KB Output is correct
115 Correct 3 ms 768 KB Output is correct
116 Correct 2 ms 640 KB Output is correct
117 Correct 14 ms 1920 KB Output is correct
118 Correct 14 ms 1920 KB Output is correct
119 Correct 25 ms 3068 KB Output is correct
120 Correct 24 ms 2940 KB Output is correct
121 Correct 24 ms 2940 KB Output is correct
122 Correct 24 ms 3068 KB Output is correct
123 Correct 24 ms 2944 KB Output is correct
124 Correct 26 ms 3064 KB Output is correct
125 Correct 25 ms 3068 KB Output is correct
126 Correct 24 ms 2940 KB Output is correct
127 Correct 27 ms 3068 KB Output is correct
128 Correct 25 ms 3060 KB Output is correct