답안 #412842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412842 2021-05-27T16:35:31 Z timmyfeng Vision Program (IOI19_vision) C++17
59 / 100
47 ms 3560 KB
#include <bits/stdc++.h>
using namespace std;

#include "vision.h"

const int L = 9;

int zero;

vector<int> dist(vector<int> cells) {
    int n = cells.size();

    vector<int> split(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        vector<int> l, r;
        for (int j = 0; j < n; ++j) {
            (j <= i ? l : r).push_back(cells[j]);
        }
        split[i] = add_and({add_or(l), add_or(r)});
    }

    vector<int> l(L, zero);
    for (int i = 0; i < L; ++i) {
        vector<int> ones, bools;
        for (int j = 0; j < n - 1; ++j) {
            if ((j & (1 << i)) > 0) {
                ones.push_back(cells[j]);
            }
            if (!ones.empty()) {
                bools.push_back(add_and({add_or(ones), split[j]}));
            }
        }
        if (!bools.empty()) {
            l[i] = add_or(bools);
        }
    }

    vector<int> r(L, zero);
    for (int i = 0; i < L; ++i) {
        vector<int> ones, bools;
        for (int j = n - 1; j > 0; --j) {
            if ((j & (1 << i)) > 0) {
                ones.push_back(cells[j]);
            }
            if (!ones.empty()) {
                bools.push_back(add_and({add_or(ones), split[j - 1]}));
            }
        }
        if (!bools.empty()) {
            r[i] = add_or(bools);
        }
    }

    vector<int> diff(L);
    int carry = zero;

    for (int i = 0; i < L; ++i) {
        diff[i] = add_xor({l[i], r[i], carry});
        carry = add_or({add_and({l[i], r[i], carry}), add_and({add_not(r[i]), add_or({l[i], carry})})});
    }

    return diff;
}

void construct_network(int h, int w, int k) {
    zero = add_and({0, add_not(0)});

    vector<int> rows(h);
    for (int i = 0; i < h; ++i) {
        vector<int> row;
        for (int j = 0; j < w; ++j) {
            row.push_back(i * w + j);
        }
        rows[i] = add_or(row);
    }

    vector<int> cols(w);
    for (int i = 0; i < w; ++i) {
        vector<int> col;
        for (int j = 0; j < h; ++j) {
            col.push_back(j * w + i);
        }
        cols[i] = add_or(col);
    }

    vector<int> r = dist(rows), c = dist(cols), sum(L);
    int carry = zero;

    for (int i = 0; i < L; ++i) {
        sum[i] = add_xor({r[i], c[i], carry});
        carry = add_or({add_and({r[i], c[i]}), add_and({r[i], carry}), add_and({c[i], carry})});
    }

    for (int i = 0; i < L; ++i) {
        if ((k & (1 << i)) == 0) {
            sum[i] = add_not(sum[i]);
        }
    }

    add_and(sum);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 292 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 292 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 1 ms 296 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 460 KB Output is correct
34 Correct 2 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 3 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 292 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 1 ms 296 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 460 KB Output is correct
34 Correct 2 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 3 ms 460 KB Output is correct
38 Correct 15 ms 1608 KB Output is correct
39 Correct 7 ms 844 KB Output is correct
40 Correct 7 ms 844 KB Output is correct
41 Correct 10 ms 1088 KB Output is correct
42 Correct 13 ms 1120 KB Output is correct
43 Correct 15 ms 1660 KB Output is correct
44 Correct 15 ms 1716 KB Output is correct
45 Correct 22 ms 1636 KB Output is correct
46 Correct 16 ms 1612 KB Output is correct
47 Correct 15 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2172 KB Output is correct
2 Correct 24 ms 2160 KB Output is correct
3 Correct 25 ms 2228 KB Output is correct
4 Correct 24 ms 2140 KB Output is correct
5 Correct 34 ms 2112 KB Output is correct
6 Correct 30 ms 2120 KB Output is correct
7 Correct 24 ms 2120 KB Output is correct
8 Correct 24 ms 2120 KB Output is correct
9 Correct 25 ms 2240 KB Output is correct
10 Correct 25 ms 2228 KB Output is correct
11 Correct 25 ms 2136 KB Output is correct
12 Correct 24 ms 2248 KB Output is correct
13 Correct 24 ms 2112 KB Output is correct
14 Correct 25 ms 2212 KB Output is correct
15 Correct 24 ms 2228 KB Output is correct
16 Correct 24 ms 2188 KB Output is correct
17 Correct 24 ms 2220 KB Output is correct
18 Correct 24 ms 2160 KB Output is correct
19 Correct 25 ms 2244 KB Output is correct
20 Correct 25 ms 2164 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 8 ms 972 KB Output is correct
4 Correct 8 ms 924 KB Output is correct
5 Correct 8 ms 932 KB Output is correct
6 Correct 8 ms 972 KB Output is correct
7 Correct 9 ms 972 KB Output is correct
8 Correct 22 ms 1480 KB Output is correct
9 Correct 15 ms 1480 KB Output is correct
10 Correct 14 ms 1480 KB Output is correct
11 Correct 14 ms 1500 KB Output is correct
12 Correct 14 ms 1572 KB Output is correct
13 Correct 25 ms 2120 KB Output is correct
14 Correct 24 ms 2120 KB Output is correct
15 Correct 24 ms 2120 KB Output is correct
16 Correct 24 ms 2196 KB Output is correct
17 Correct 24 ms 2232 KB Output is correct
18 Correct 24 ms 2212 KB Output is correct
19 Correct 34 ms 2124 KB Output is correct
20 Correct 34 ms 3560 KB Output is correct
21 Correct 36 ms 3532 KB Output is correct
22 Correct 36 ms 3520 KB Output is correct
23 Correct 36 ms 3528 KB Output is correct
24 Correct 36 ms 3476 KB Output is correct
25 Correct 47 ms 3516 KB Output is correct
26 Correct 39 ms 3488 KB Output is correct
27 Incorrect 4 ms 2248 KB WA in grader: Too many instructions
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2248 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 292 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 1 ms 296 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 460 KB Output is correct
34 Correct 2 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 3 ms 460 KB Output is correct
38 Correct 15 ms 1608 KB Output is correct
39 Correct 7 ms 844 KB Output is correct
40 Correct 7 ms 844 KB Output is correct
41 Correct 10 ms 1088 KB Output is correct
42 Correct 13 ms 1120 KB Output is correct
43 Correct 15 ms 1660 KB Output is correct
44 Correct 15 ms 1716 KB Output is correct
45 Correct 22 ms 1636 KB Output is correct
46 Correct 16 ms 1612 KB Output is correct
47 Correct 15 ms 1668 KB Output is correct
48 Correct 24 ms 2172 KB Output is correct
49 Correct 24 ms 2160 KB Output is correct
50 Correct 25 ms 2228 KB Output is correct
51 Correct 24 ms 2140 KB Output is correct
52 Correct 34 ms 2112 KB Output is correct
53 Correct 30 ms 2120 KB Output is correct
54 Correct 24 ms 2120 KB Output is correct
55 Correct 24 ms 2120 KB Output is correct
56 Correct 25 ms 2240 KB Output is correct
57 Correct 25 ms 2228 KB Output is correct
58 Correct 25 ms 2136 KB Output is correct
59 Correct 24 ms 2248 KB Output is correct
60 Correct 24 ms 2112 KB Output is correct
61 Correct 25 ms 2212 KB Output is correct
62 Correct 24 ms 2228 KB Output is correct
63 Correct 24 ms 2188 KB Output is correct
64 Correct 24 ms 2220 KB Output is correct
65 Correct 24 ms 2160 KB Output is correct
66 Correct 25 ms 2244 KB Output is correct
67 Correct 25 ms 2164 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 2 ms 204 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 2 ms 204 KB Output is correct
72 Correct 8 ms 972 KB Output is correct
73 Correct 8 ms 924 KB Output is correct
74 Correct 8 ms 932 KB Output is correct
75 Correct 8 ms 972 KB Output is correct
76 Correct 9 ms 972 KB Output is correct
77 Correct 22 ms 1480 KB Output is correct
78 Correct 15 ms 1480 KB Output is correct
79 Correct 14 ms 1480 KB Output is correct
80 Correct 14 ms 1500 KB Output is correct
81 Correct 14 ms 1572 KB Output is correct
82 Correct 25 ms 2120 KB Output is correct
83 Correct 24 ms 2120 KB Output is correct
84 Correct 24 ms 2120 KB Output is correct
85 Correct 24 ms 2196 KB Output is correct
86 Correct 24 ms 2232 KB Output is correct
87 Correct 24 ms 2212 KB Output is correct
88 Correct 34 ms 2124 KB Output is correct
89 Correct 34 ms 3560 KB Output is correct
90 Correct 36 ms 3532 KB Output is correct
91 Correct 36 ms 3520 KB Output is correct
92 Correct 36 ms 3528 KB Output is correct
93 Correct 36 ms 3476 KB Output is correct
94 Correct 47 ms 3516 KB Output is correct
95 Correct 39 ms 3488 KB Output is correct
96 Incorrect 4 ms 2248 KB WA in grader: Too many instructions
97 Halted 0 ms 0 KB -