답안 #403112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403112 2021-05-12T18:58:59 Z rocks03 Vision Program (IOI19_vision) C++14
0 / 100
10 ms 1100 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int add_and(vector<int> Ns);
int add_or(vector<int> Ns);
int add_xor(vector<int> Ns);
int add_not(int N);

int H, W, K;

bool valid(int x, int y){
    return (x >= 0 && x < H && y >= 0 && y < W);
}
int dist(int x, int y, int x2, int y2){
    assert(valid(x, y)); assert(valid(x2, y2));
    return abs(x - x2) + abs(y - y2);
}
int cell(int x, int y){
    assert(valid(x, y));
    return x * W + y;
}

void sub6(){
    int cnt = H * W; vector<int> answer;
    vector<int> colonna(W);
    rep(w, 0, W){
        vector<int> v;
        rep(h, 0, H){
            v.pb(cell(h, w));
        }
        add_or(v); colonna[w] = cnt++;
    }
    vector<int> tot;
    rep(w, 0, W) tot.pb(colonna[w]);
    add_xor(tot); int c0 = cnt++;
    add_not(c0); c0 = cnt++;

    vector<int> riga(H);
    rep(h, 0, H){
        vector<int> v;
        rep(w, 0, W){
            v.pb(cell(h, w));
        }
        add_or(v); riga[h] = cnt++;
    }

    tot.clear();
    rep(h, 0, H) tot.pb(riga[h]);
    add_xor(tot); int r0 = cnt++;
    add_not(r0); r0 = cnt++;

    rep(h, 1, H){
        vector<int> v;
        v = {riga[h - 1], riga[h], c0};
        add_and(v); answer.pb(cnt); cnt++;
    }
    rep(w, 1, W){
        vector<int> v;
        v = {colonna[w - 1], colonna[w], r0};
        add_and(v); answer.pb(cnt); cnt++;
    }
    add_or(answer);
}

void construct_network(int H, int W, int K){
    ::H = H, ::W = W, ::K = K;
    if(K == 1){
        sub6();
    } else{
        int cnt = H * W;
        vector<int> v;
        rep(h, 0, H){
            rep(w, 0, W){
                vector<int> v2;
                rep(h2, 0, H){
                    rep(w2, 0, W){
                        if(dist(h, w, h2, w2) == K){
                            v2.pb(cell(h2, w2));
                        }
                    }
                }
                if(!SZ(v2)) continue;
                add_or(v2);
                add_and({cell(h, w), cnt});
                cnt++;
                v.pb(cnt);
                cnt++;
            }
        }
        add_or(v);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1100 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -