Submission #422920

# Submission time Handle Problem Language Result Execution time Memory
422920 2021-06-10T14:10:09 Z yuto1115 Vision Program (IOI19_vision) C++17
100 / 100
47 ms 1920 KB
#include "vision.h"
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++)
#define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int inf = 1001001001;
const ll linf = 1001001001001001001;

template<class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void construct_network(int h, int w, int k) {
    int s = h + w - 1;
    vi tmp;
    rep(i, h) rep(j, w) tmp.pb(i * w + j);
    int F1 = add_or(tmp);
    int F0 = add_not(F1);
    auto get = [&](int i, int j) -> int {
        assert(0 <= i and i < 13);
        if (i < 12) assert(0 <= j and j < s);
        else
            assert(0 <= j and j < 8);
        return h * w + 2 + s * i + j;
    };
    // r + c
    {
        rep(i, s) {
            vi ls;
            rep(r, h) rep(c, w) {
                    if (r + c == i) ls.pb(r * w + c);
                }
            add_or(ls);
        }
        rep(i, s) add_not(get(0, i));
        add_or({get(0, 0)});
        rep2(i, 1, s) add_or({get(2, i - 1), get(0, i)});
        rep(i, s) add_not(get(2, i));
        rep(i, s) {
            if (i > k) {
                add_or({get(1, i), get(3, i - k - 1)});
            } else {
                add_not(F0);
            }
        };
        rep(i, s) {
            if (i >= k) {
                add_or({get(1, i), get(3, i - k)});
            } else {
                add_not(F0);
            }
        };
    }
    // r - c
    {
        rep2(i, -w + 1, h) {
            vi ls;
            rep(r, h) rep(c, w) {
                    if (r - c == i) ls.pb(r * w + c);
                }
            add_or(ls);
        }
        rep(i, s) add_not(get(6, i));
        add_or({get(6, 0)});
        rep2(i, 1, s) add_or({get(8, i - 1), get(6, i)});
        rep(i, s) add_not(get(8, i));
        rep(i, s) {
            if (i > k) {
                add_or({get(7, i), get(9, i - k - 1)});
            } else {
                add_not(F0);
            }
        };
        rep(i, s) {
            if (i >= k) {
                add_or({get(7, i), get(9, i - k)});
            } else {
                add_not(F0);
            }
        };
    }
    tmp.clear();
    rep(i, s) tmp.pb(get(4, i));
    add_and(tmp);
    tmp.clear();
    rep(i, s) tmp.pb(get(10, i));
    add_and(tmp);
    tmp.clear();
    rep(i, s) tmp.pb(get(5, i));
    add_and(tmp);
    tmp.clear();
    rep(i, s) tmp.pb(get(11, i));
    add_and(tmp);
    add_and({get(12, 0), get(12, 1)});
    add_and({get(12, 2), get(12, 3)});
    add_not(get(12, 5));
    add_and({get(12, 4), get(12, 6)});
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 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 312 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 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 312 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 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 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 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 312 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 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 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 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 312 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 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 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 8 ms 716 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 4 ms 460 KB Output is correct
42 Correct 4 ms 460 KB Output is correct
43 Correct 8 ms 836 KB Output is correct
44 Correct 9 ms 716 KB Output is correct
45 Correct 8 ms 716 KB Output is correct
46 Correct 8 ms 716 KB Output is correct
47 Correct 8 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 460 KB Output is correct
13 Correct 2 ms 460 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 3 ms 476 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 7 ms 588 KB Output is correct
9 Correct 6 ms 588 KB Output is correct
10 Correct 5 ms 588 KB Output is correct
11 Correct 5 ms 588 KB Output is correct
12 Correct 5 ms 588 KB Output is correct
13 Correct 2 ms 460 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 3 ms 460 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 17 ms 1020 KB Output is correct
21 Correct 18 ms 1040 KB Output is correct
22 Correct 18 ms 1020 KB Output is correct
23 Correct 19 ms 1012 KB Output is correct
24 Correct 17 ms 1024 KB Output is correct
25 Correct 16 ms 1020 KB Output is correct
26 Correct 22 ms 1012 KB Output is correct
27 Correct 46 ms 1840 KB Output is correct
28 Correct 36 ms 1900 KB Output is correct
29 Correct 36 ms 1864 KB Output is correct
30 Correct 36 ms 1820 KB Output is correct
31 Correct 36 ms 1852 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1812 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 460 KB Output is correct
4 Correct 5 ms 588 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 20 ms 1028 KB Output is correct
8 Correct 18 ms 1020 KB Output is correct
9 Correct 36 ms 1832 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 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 312 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 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 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 8 ms 716 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 4 ms 460 KB Output is correct
42 Correct 4 ms 460 KB Output is correct
43 Correct 8 ms 836 KB Output is correct
44 Correct 9 ms 716 KB Output is correct
45 Correct 8 ms 716 KB Output is correct
46 Correct 8 ms 716 KB Output is correct
47 Correct 8 ms 760 KB Output is correct
48 Correct 2 ms 460 KB Output is correct
49 Correct 2 ms 460 KB Output is correct
50 Correct 2 ms 460 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 2 ms 460 KB Output is correct
53 Correct 2 ms 460 KB Output is correct
54 Correct 2 ms 460 KB Output is correct
55 Correct 2 ms 460 KB Output is correct
56 Correct 2 ms 460 KB Output is correct
57 Correct 2 ms 460 KB Output is correct
58 Correct 2 ms 504 KB Output is correct
59 Correct 2 ms 460 KB Output is correct
60 Correct 2 ms 460 KB Output is correct
61 Correct 2 ms 460 KB Output is correct
62 Correct 2 ms 460 KB Output is correct
63 Correct 2 ms 460 KB Output is correct
64 Correct 2 ms 460 KB Output is correct
65 Correct 2 ms 460 KB Output is correct
66 Correct 2 ms 460 KB Output is correct
67 Correct 2 ms 460 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 0 ms 204 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 3 ms 460 KB Output is correct
73 Correct 3 ms 476 KB Output is correct
74 Correct 3 ms 460 KB Output is correct
75 Correct 3 ms 460 KB Output is correct
76 Correct 3 ms 460 KB Output is correct
77 Correct 7 ms 588 KB Output is correct
78 Correct 6 ms 588 KB Output is correct
79 Correct 5 ms 588 KB Output is correct
80 Correct 5 ms 588 KB Output is correct
81 Correct 5 ms 588 KB Output is correct
82 Correct 2 ms 460 KB Output is correct
83 Correct 2 ms 460 KB Output is correct
84 Correct 2 ms 512 KB Output is correct
85 Correct 2 ms 460 KB Output is correct
86 Correct 2 ms 460 KB Output is correct
87 Correct 3 ms 460 KB Output is correct
88 Correct 2 ms 460 KB Output is correct
89 Correct 17 ms 1020 KB Output is correct
90 Correct 18 ms 1040 KB Output is correct
91 Correct 18 ms 1020 KB Output is correct
92 Correct 19 ms 1012 KB Output is correct
93 Correct 17 ms 1024 KB Output is correct
94 Correct 16 ms 1020 KB Output is correct
95 Correct 22 ms 1012 KB Output is correct
96 Correct 46 ms 1840 KB Output is correct
97 Correct 36 ms 1900 KB Output is correct
98 Correct 36 ms 1864 KB Output is correct
99 Correct 36 ms 1820 KB Output is correct
100 Correct 36 ms 1852 KB Output is correct
101 Correct 1 ms 204 KB Output is correct
102 Correct 1 ms 204 KB Output is correct
103 Correct 47 ms 1812 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 3 ms 460 KB Output is correct
106 Correct 5 ms 588 KB Output is correct
107 Correct 2 ms 460 KB Output is correct
108 Correct 2 ms 460 KB Output is correct
109 Correct 20 ms 1028 KB Output is correct
110 Correct 18 ms 1020 KB Output is correct
111 Correct 36 ms 1832 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 37 ms 1808 KB Output is correct
115 Correct 2 ms 460 KB Output is correct
116 Correct 2 ms 460 KB Output is correct
117 Correct 24 ms 1012 KB Output is correct
118 Correct 21 ms 1148 KB Output is correct
119 Correct 36 ms 1792 KB Output is correct
120 Correct 43 ms 1816 KB Output is correct
121 Correct 38 ms 1800 KB Output is correct
122 Correct 36 ms 1844 KB Output is correct
123 Correct 38 ms 1864 KB Output is correct
124 Correct 36 ms 1864 KB Output is correct
125 Correct 36 ms 1920 KB Output is correct
126 Correct 37 ms 1820 KB Output is correct
127 Correct 36 ms 1832 KB Output is correct
128 Correct 44 ms 1792 KB Output is correct