This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
void construct_network(int H, int W, int K) {
h = H, w = W, k = K;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |