답안 #294609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
294609 2020-09-09T06:56:51 Z 2qbingxuan Vision Program (IOI19_vision) C++14
12 / 100
4 ms 1792 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;
        }
    }
    safe;
    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_or(diag[c][i]);
                diagId[c][i] = 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++;
    }
    vector<int> maybe;
    debug(zero);
    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[0][x+k] is True, and sum(y, [y-k .. y+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++);
            }
        }
    }
    add_or(maybe);
    safe;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Incorrect 0 ms 256 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Incorrect 0 ms 256 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Incorrect 0 ms 256 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Incorrect 0 ms 256 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 384 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 1 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB on inputs (0, 0), (1, 1), expected 1, but computed 0
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1792 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Incorrect 0 ms 256 KB on inputs (0, 1), (1, 0), expected 1, but computed 0
7 Halted 0 ms 0 KB -