Submission #573924

# Submission time Handle Problem Language Result Execution time Memory
573924 2022-06-07T12:24:58 Z Stickfish Vision Program (IOI19_vision) C++17
100 / 100
58 ms 5784 KB
#include "vision.h"
#include <functional>
#include <iostream>
using namespace std;

int memsz;

struct cords {
    bool rvs;
    int h;
    int w;

    int get_num(int i, int j) const {
        if (rvs)
            j = w - j - 1;
        return i * w + j;
    }
};

int get_downright(int h, int w, int k, cords cr) {
    vector<vector<int>> diags(w + h - 1);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            diags[i + j].push_back(cr.get_num(i, j));
        }
    }
    vector<int> diag_nums;
    for (int i = 0; i < h + w - 1; ++i) {
        add_xor(diags[i]);
        diag_nums.push_back(memsz);
        ++memsz;
    }
    vector<int> diag_pairs;
    for (int i = 0; i + k < h + w - 1; ++i) {
        add_and({diag_nums[i], diag_nums[i + k]});
        diag_pairs.push_back(memsz);
        ++memsz;
    }
    add_or(diag_pairs);
    int diag_check = memsz;
    ++memsz;
    vector<vector<bool>> used(h, vector<bool>(w, false));
    vector<vector<int>> end_mem(h, vector<int>(w, -1));
    vector<int> direction_check;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (!used[i][j]) {
                vector<int> start;
                vector<int> end;
                if (i && end_mem[i - 1][j] != -1)
                    end.push_back(end_mem[i - 1][j]);
                for (int j0 = j; j0 < w; j0 += 3 * k) {
                    for (int j1 = j0; j1 < j0 + k && j1 < w; ++j1) {
                        start.push_back(cr.get_num(i, j1));
                        used[i][j1] = true;
                        if (i == 0 || end_mem[i - 1][j] == -1) {
                            for (int i1 = i; i1 < h && i1 <= i + k; ++i1) {
                                if (j1 + k - (i1 - i) < w)
                                    end.push_back(cr.get_num(i1, j1 + k - (i1 - i)));
                            }
                        } else {
                            if (j1 + k < w)
                                end.push_back(cr.get_num(i - 1, j1 + k));
                            if (i + k < h)
                                end.push_back(cr.get_num(i + k, j1));
                            int t = (j0 + k - j1) - 1;
                            if (i + t < h) {
                                end.push_back(cr.get_num(i + t, j1));
                                if (j1 + k < w)
                                    end.push_back(cr.get_num(i + t, j1 + k));
                            }
                        }
                    }
                }
                if (start.empty() || end.empty())
                    continue;
                //for (auto x : start)
                    //cout << x << ' ';
                //cout << "| ";
                //for (auto x : end)
                    //cout << x << ' ';
                //cout << endl;
                add_xor(start);
                ++memsz;
                add_xor(end);
                end_mem[i][j] = memsz;
                ++memsz;
                add_and({memsz - 2, memsz - 1});
                direction_check.push_back(memsz);
                ++memsz;
            }
        }
    }
    add_or(direction_check);
    ++memsz;
    add_and({memsz - 1, diag_check});
    ++memsz;
    return memsz - 1;
}


void construct_network(int h, int w, int k) {
    int cnt = h * w;
    memsz = h * w;
    cords c;
    c.rvs = 0;
    c.h = h;
    c.w = w;
    int ans0 = get_downright(h, w, k, c);
    c.rvs = 1;
    int ans1 = get_downright(h, w, k, c);
    if (ans0 == -1)
        return;
    if (ans1 == -1) {
        add_and({ans0});
        return;
    }
    add_or({ans0, ans1});
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:103:9: warning: unused variable 'cnt' [-Wunused-variable]
  103 |     int cnt = h * w;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 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 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 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 304 KB Output is correct
38 Correct 10 ms 1236 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 7 ms 980 KB Output is correct
42 Correct 3 ms 552 KB Output is correct
43 Correct 16 ms 1596 KB Output is correct
44 Correct 13 ms 1364 KB Output is correct
45 Correct 7 ms 940 KB Output is correct
46 Correct 8 ms 880 KB Output is correct
47 Correct 5 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 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 2 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 752 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 3 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 8 ms 1012 KB Output is correct
9 Correct 6 ms 852 KB Output is correct
10 Correct 4 ms 596 KB Output is correct
11 Correct 4 ms 596 KB Output is correct
12 Correct 3 ms 596 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 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 26 ms 3040 KB Output is correct
21 Correct 15 ms 2004 KB Output is correct
22 Correct 11 ms 1620 KB Output is correct
23 Correct 9 ms 1444 KB Output is correct
24 Correct 26 ms 2908 KB Output is correct
25 Correct 14 ms 1792 KB Output is correct
26 Correct 10 ms 1268 KB Output is correct
27 Correct 50 ms 5704 KB Output is correct
28 Correct 36 ms 4496 KB Output is correct
29 Correct 25 ms 3276 KB Output is correct
30 Correct 19 ms 2588 KB Output is correct
31 Correct 17 ms 2352 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 5784 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 812 KB Output is correct
4 Correct 8 ms 980 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 31 ms 3024 KB Output is correct
8 Correct 25 ms 2948 KB Output is correct
9 Correct 52 ms 5700 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 296 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 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 304 KB Output is correct
38 Correct 10 ms 1236 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 7 ms 980 KB Output is correct
42 Correct 3 ms 552 KB Output is correct
43 Correct 16 ms 1596 KB Output is correct
44 Correct 13 ms 1364 KB Output is correct
45 Correct 7 ms 940 KB Output is correct
46 Correct 8 ms 880 KB Output is correct
47 Correct 5 ms 724 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 1 ms 468 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 1 ms 468 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 2 ms 468 KB Output is correct
63 Correct 2 ms 468 KB Output is correct
64 Correct 1 ms 468 KB Output is correct
65 Correct 1 ms 468 KB Output is correct
66 Correct 1 ms 468 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 5 ms 752 KB Output is correct
73 Correct 3 ms 596 KB Output is correct
74 Correct 3 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 8 ms 1012 KB Output is correct
78 Correct 6 ms 852 KB Output is correct
79 Correct 4 ms 596 KB Output is correct
80 Correct 4 ms 596 KB Output is correct
81 Correct 3 ms 596 KB Output is correct
82 Correct 1 ms 340 KB Output is correct
83 Correct 1 ms 340 KB Output is correct
84 Correct 1 ms 340 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 1 ms 468 KB Output is correct
87 Correct 1 ms 468 KB Output is correct
88 Correct 1 ms 468 KB Output is correct
89 Correct 26 ms 3040 KB Output is correct
90 Correct 15 ms 2004 KB Output is correct
91 Correct 11 ms 1620 KB Output is correct
92 Correct 9 ms 1444 KB Output is correct
93 Correct 26 ms 2908 KB Output is correct
94 Correct 14 ms 1792 KB Output is correct
95 Correct 10 ms 1268 KB Output is correct
96 Correct 50 ms 5704 KB Output is correct
97 Correct 36 ms 4496 KB Output is correct
98 Correct 25 ms 3276 KB Output is correct
99 Correct 19 ms 2588 KB Output is correct
100 Correct 17 ms 2352 KB Output is correct
101 Correct 1 ms 212 KB Output is correct
102 Correct 1 ms 212 KB Output is correct
103 Correct 58 ms 5784 KB Output is correct
104 Correct 0 ms 212 KB Output is correct
105 Correct 5 ms 812 KB Output is correct
106 Correct 8 ms 980 KB Output is correct
107 Correct 1 ms 340 KB Output is correct
108 Correct 2 ms 468 KB Output is correct
109 Correct 31 ms 3024 KB Output is correct
110 Correct 25 ms 2948 KB Output is correct
111 Correct 52 ms 5700 KB Output is correct
112 Correct 0 ms 212 KB Output is correct
113 Correct 0 ms 212 KB Output is correct
114 Correct 37 ms 4480 KB Output is correct
115 Correct 1 ms 340 KB Output is correct
116 Correct 2 ms 468 KB Output is correct
117 Correct 10 ms 1364 KB Output is correct
118 Correct 22 ms 2536 KB Output is correct
119 Correct 25 ms 3292 KB Output is correct
120 Correct 24 ms 3112 KB Output is correct
121 Correct 25 ms 3148 KB Output is correct
122 Correct 26 ms 3212 KB Output is correct
123 Correct 48 ms 5732 KB Output is correct
124 Correct 37 ms 4428 KB Output is correct
125 Correct 25 ms 3284 KB Output is correct
126 Correct 25 ms 3136 KB Output is correct
127 Correct 19 ms 2536 KB Output is correct
128 Correct 18 ms 2364 KB Output is correct