제출 #299554

#제출 시각아이디문제언어결과실행 시간메모리
299554Aldas25Vision Program (IOI19_vision)C++14
44 / 100
456 ms3188 KiB
#include "vision.h"
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;

const int MAXN = 500100;

int h, w, k;

int getId (int i, int j) {
    return i*w + j;
}

vi getHalfCircle (int i, int j) {
    vi ret;
    FOR(x, 0, h-1) FOR(y, 0, w-1) {
        if (x < i) continue;
        if (x == i && y <= j) continue;
        int d = abs(x-i) + abs(y-j);
        if (d == k) ret.pb(getId(x,y));
    }
    return ret;
}

vi getFullCircle (int i, int j) {
    vi ret;
    FOR(x, 0, h-1) FOR(y, 0, w-1) {
        //if (x < i) continue;
        //if (x == i && y <= j) continue;
        int d = abs(x-i) + abs(y-j);
        if (d == k) ret.pb(getId(x,y));
    }
    return ret;
}

void construct_network(int H, int W, int K) {
    h = H, w = W, k = K;

    if (k == 1) {
        vi seq;
        FOR(i, 0, h-1) FOR(j, 0, w-1) {
            if ((i+j)%2 == 1) continue;
            vi circle = getFullCircle(i,j);
            if ((int)circle.size() == 0) continue;
            add_or(circle);
            seq.pb(getId(i,j));
        }

        FOR(i, 0, (int)seq.size()-1) {
            add_and({seq[i], h*w + i});
        }

        int x = (int)seq.size();
        seq.clear();
        FOR(i, 0, x-1)
            seq.pb(h*w+x+i);

        add_or(seq);
        return;
    }

    vi seq;
    FOR(i, 0, h-1) FOR(j, 0, w-1) {
        vi circle = getHalfCircle(i,j);
        if ((int)circle.size() == 0) continue;
        add_or(circle);
        seq.pb(getId(i,j));
    }

    FOR(i, 0, (int)seq.size()-1) {
        add_and({seq[i], h*w + i});
    }

    int x = (int)seq.size();
    seq.clear();
    FOR(i, 0, x-1)
        seq.pb(h*w+x+i);

    add_or(seq);

}

/*

2 3 3
0 0 0 1
0 0 0 2
0 0 1 0
0 0 1 1
0 0 1 2
0 1 0 2
0 1 1 0
0 1 1 1
0 1 1 2
0 2 1 0
0 2 1 1
0 2 1 2
1 0 1 1
1 0 1 2
1 1 1 2
-1
out:
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0


*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...