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;
int h,w,k;
bool bounds(int y, int x) {
if(y >= 0 && x >= 0 && y < h && x < w) return true;
return false;
}
void construct_network(int H, int W, int K) {
h=H; w=W; k=K;
int index = H*W;
vector<vector<vector<vector<bool>>>> have_used(w, vector<vector<vector<bool>>>(h, vector<vector<bool>>(w, vector<bool>(h, false))));
for(int y = 0; y < H; y++) {
for(int x = 0; x < W; x++) {
for(int i = 0; i <= K; i++) {
int fdir = i;
int sdir = K-i;
int ny = y+fdir;
int nx = x+sdir;
if(bounds(ny, nx) && !have_used[x][y][nx][ny]) {
add_and({y*w + x, ny*w + nx});
index++;
have_used[x][y][nx][ny] = true;
have_used[nx][ny][x][y] = true;
}
ny = y-fdir;
nx = x+sdir;
if(bounds(ny, nx) && !have_used[x][y][nx][ny]) {
add_and({y*w + x, ny*w + nx});
index++;
have_used[x][y][nx][ny] = true;
have_used[nx][ny][x][y] = true;
}
ny = y-fdir;
nx = x-sdir;
if(bounds(ny, nx) && !have_used[x][y][nx][ny]) {
add_and({y*w + x, ny*w + nx});
index++;
have_used[x][y][nx][ny] = true;
have_used[nx][ny][x][y] = true;
}
ny = y+fdir;
nx = x-sdir;
if(bounds(ny, nx) && !have_used[x][y][nx][ny]) {
add_and({y*w + x, ny*w + nx});
index++;
have_used[x][y][nx][ny] = true;
have_used[nx][ny][x][y] = true;
}
}
}
}
vector<int> Ns;
for(int i = H*W; i < index; i++) {
Ns.push_back(i);
}
add_or(Ns);
}
# | 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... |