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 <bits/stdc++.h>
#include "vision.h"
using namespace std;
bool viz[205][205], cul[205][205];
int wh[205][205];
int H, W, K;
void paint(int i, int j){
if(cul[i][j]) return ;
for(int x = -K; x <= K ; ++x){
int y = K - abs(x);
int l = i + x, c = j + y;
if(l >= 0 && c >= 0 && l < H && c < W) cul[l][c] = 1;
y = -y; l = i + x, c = j + y;
if(l >= 0 && c >= 0 && l < H && c < W) cul[l][c] = 1;
}
}
void construct_network(int n, int m, int k) {
vector <int> v;
H = n; W = m; K = k;
int mi = H / 2, mj = W / 2;
for(int d = 0; d <= max(H, W) ; ++d){
for(int i = max(0, mi - d); i <= max(H - 1, mi + d) ; ++i){
if(mj - d >= 0) paint(i, mj - d);
if(mj + d < W) paint(i, mj + d);
}
for(int j = max(0, mj - d); j <= max(W - 1, mj + d) ; ++j){
if(mi - d >= 0) paint(mi - d, j);
if(mi + d < H) paint(mi + d, j);
}
}
int Last = 0;
for(int i = 0; i < H ; ++i){
for(int j = 0; j < W ; ++j){
if(!cul[i][j]) continue ;
viz[i][j] = 1;
v.clear();
for(int x = -K; x <= K ; ++x){
int y = K - abs(x);
int l = i + x, c = j + y;
if(l >= 0 && c >= 0 && l < H && c < W){
if(!viz[l][c]) v.push_back(l * W + c);
}
y = -y;
l = i + x, c = j + y;
if(l >= 0 && c >= 0 && l < H && c < W){
if(!viz[l][c]) v.push_back(l * W + c);
}
}
if(v.size() == 0) continue ;
wh[i][j] = add_or(v);
Last = wh[i][j];
}
}
int st = Last + 1, dr = 0;
for(int i = 0; i < H ; ++i){
for(int j = 0; j < W ; ++j){
if(wh[i][j]){
vector <int> v;
v.push_back(i * W + j);
v.push_back(wh[i][j]);
dr = add_and(v);
}
}
}
v.clear();
for(int i = st; i <= dr ; ++i) v.push_back(i);
add_or(v);
return ;
}
# | 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... |