Submission #294618

# Submission time Handle Problem Language Result Execution time Memory
294618 2020-09-09T07:26:03 Z 2qbingxuan Vision Program (IOI19_vision) C++14
12 / 100
14 ms 1920 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<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++;
            }
        }
    }
    debug(tot);
    vector<vector<int>> preId(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++;
    }
    debug(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 = 0; i < H+W; i++) {
        int l = i-k <= 0 ? zero : preId[c][i-k-1];
        int r = preId[c][min(H+W-1, i+k)];
        add_xor({l, r});
        add_not(tot++);
        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});
    /*
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int x = i+j;
            int y = i-j+W-1;
            // x' = x+k, y' \in [y-k, y+k]
            if(x+k < H+W) {
                // ensure diag[0][x+k] is True, and sum(y, [y-k .. y+k]) is even
                int l = y-k <= 0 ? zero : preId[1][y-k-1];
                int r = y+k < H+W ? preId[1][y+k] : preId[1][H+W-1];
                add_xor({l, r});
                add_not(tot++);
                vector<int> dep{ id[i][j], diagId[0][x+k], tot++ };
                add_and(dep);
                maybe.pb(tot++);
            }
            if(y+k < H+W) {
                // ensure diag[1][y+k] is True, and sum(x, [x-k .. x+k]) is even
                int l = x-k <= 0 ? zero : preId[0][x-k-1];
                int r = x+k < H+W ? preId[0][x+k] : preId[0][H+W-1];
                add_xor({l, r});
                add_not(tot++);
                vector<int> dep{ id[i][j], diagId[1][y+k], tot++ };
                add_and(dep);
                maybe.pb(tot++);
            }
            debug(tot);
        }
    }
    */
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 0 ms 256 KB Output is correct
6 Correct 0 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 1 ms 256 KB Output is correct
10 Correct 0 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 Incorrect 1 ms 256 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 0 ms 256 KB Output is correct
6 Correct 0 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 1 ms 256 KB Output is correct
10 Correct 0 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 Incorrect 1 ms 256 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 0 ms 256 KB Output is correct
6 Correct 0 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 1 ms 256 KB Output is correct
10 Correct 0 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 Incorrect 1 ms 256 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 0 ms 256 KB Output is correct
6 Correct 0 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 1 ms 256 KB Output is correct
10 Correct 0 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 Incorrect 1 ms 256 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 2 ms 640 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 3 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 3 ms 640 KB Output is correct
12 Correct 3 ms 640 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 7 ms 1152 KB Output is correct
21 Incorrect 7 ms 1152 KB on inputs (0, 0), (199, 99), expected 0, but computed 1
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1920 KB on inputs (126, 120), (176, 169), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 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 0 ms 256 KB Output is correct
6 Correct 0 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 1 ms 256 KB Output is correct
10 Correct 0 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 Incorrect 1 ms 256 KB on inputs (0, 2), (1, 0), expected 0, but computed 1
14 Halted 0 ms 0 KB -