답안 #281692

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
281692 2020-08-23T10:00:06 Z NONAME Vision Program (IOI19_vision) C++14
66 / 100
16 ms 1280 KB
#include "vision.h"

void construct_network(int H, int W, int K) {
    std::vector <int> res, res1;

    if ((H == 1) || (W == 1)) {
        int cnt = 0;
        for (int x1 = 0; x1 < H; ++x1)
        for (int y1 = 0; y1 < W; ++y1) {
            std::vector <int> cur;

            for (int x2 = 0; x2 < H; ++x2)
            for (int y2 = 0; y2 < W; ++y2) {
                if ((abs(x1 - x2) + abs(y1 - y2)) != K)
                    continue;

                cur.push_back(x2 * W + y2);
            }

            if (cur.empty())
                continue;

            add_or(cur);
            res.push_back(H * W + cnt);
            ++cnt;
            add_and({x1 * W + y1, res.back()});
            res1.push_back(H * W + cnt);
            ++cnt;
        }

        add_or(res1);
        return;
    }
    if (K == 1) {
        std::vector <int> row, col;
        for (int i = 0; i < H; ++i) {
            std::vector <int> cur;
            for (int j = 0; j < W; ++j)
                cur.push_back(i * W + j);

            int x = add_or(cur);
            row.push_back(x);
        }

        for (int j = 0; j < W; ++j) {
            std::vector <int> cur;
            for (int i = 0; i < H; ++i)
                cur.push_back(i * W + j);

            int x = add_or(cur);
            col.push_back(x);
        }
                         
        int rs1 = -1;
        if ((int)(row.size()) == 1) rs1 = row[0];
            else {
                rs1 = add_and({row[0], row[1]});
                for (int i = 1; i < H - 1; ++i)
                    rs1 = add_or({rs1, add_and({row[i], row[i + 1]})});
            }
                                                                   
        int rs2 = -1;
        if ((int)(col.size()) == 1) rs2 = col[0];
            else {
                rs2 = add_and({col[0], col[1]});
                for (int i = 1; i < W - 1; ++i)
                    rs2 = add_or({rs2, add_and({col[i], col[i + 1]})});
            }
        int total = add_xor({rs1, rs2});    

        int result = row[0];
        for (int i = 1; i < H; ++i)
            result = add_xor({result, row[i]});

        for (int i = 0; i < W; ++i)
            result = add_xor({(result == -1) ? col[i] : result, col[i]});

        add_and({total, result});

        return;
    }

    if (((H > 30) || (W > 30)) && (H > 1) && (W > 1)) {
        for (int x = 0; x < H; ++x)
        for (int y = 0; y < W; ++y) {
            if (x + y != K)
                continue;
            
            res.push_back(x * W + y);
        }

        add_or(res);
        add_and({0, H * W});
    } else {
        int cnt = 0;
        for (int x1 = 0; x1 < H; ++x1)
        for (int y1 = 0; y1 < W; ++y1) {
            std::vector <int> cur;

            for (int x2 = 0; x2 < H; ++x2)
            for (int y2 = 0; y2 < W; ++y2) {
                if ((abs(x1 - x2) + abs(y1 - y2)) != K)
                    continue;

                cur.push_back(x2 * W + y2);
            }

            if (cur.empty())
                continue;

            add_or(cur);
            res.push_back(H * W + cnt);
            ++cnt;
            add_and({x1 * W + y1, res.back()});
            res1.push_back(H * W + cnt);
            ++cnt;
        }

        add_or(res1);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 256 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 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 256 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 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 6 ms 640 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 6 ms 640 KB Output is correct
35 Correct 5 ms 640 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 256 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 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 6 ms 640 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 6 ms 640 KB Output is correct
35 Correct 5 ms 640 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Incorrect 0 ms 256 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 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 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 0 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 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 6 ms 768 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 9 ms 768 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 0 ms 256 KB Output is correct
27 Correct 15 ms 1280 KB Output is correct
28 Correct 1 ms 256 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 0 ms 256 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1152 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 3 ms 488 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 6 ms 768 KB Output is correct
8 Correct 7 ms 768 KB Output is correct
9 Correct 11 ms 1280 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 256 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 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 6 ms 640 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 6 ms 640 KB Output is correct
35 Correct 5 ms 640 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 1 ms 256 KB Output is correct
38 Incorrect 0 ms 256 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
39 Halted 0 ms 0 KB -