#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
#define MAXH 205
#define MAXW 205
int h,w,k;
int cnt[MAXH*MAXW];
int st[MAXH*MAXW];
set<pair<int,int>> used;
vector<int> diag;
vector<int> answers;
int id(int x,int y){//x in 0..h-1, y in 0..w-1
return x*w+y;
}
bool inbounds(int x,int y){
return 0<=x&&x<h&&0<=y&&y<w;
}
void ins_cnt(int x,int y,int dx,int dy){
int x_=x+dx;
int y_=y+dy;
if(inbounds(x_,y_)){
cnt[id(x,y)]++;
}
}
int argmax(int a,int b){
return cnt[a]>cnt[b]?a:b;
}
void build(int v=1,int start=0,int end=h*w-1){
if(start==end){
st[v]=start;
return;
}
int mid=(start+end)/2;
build(2*v,start,mid);
build(2*v+1,mid+1,end);
st[v]=argmax(st[2*v],st[2*v+1]);
}
void update(int pos,int v=1,int start=0,int end=h*w-1){
if(start==end){
return;
}
int mid=(start+end)/2;
if(pos<=mid){
update(pos,2*v,start,mid);
}else{
update(pos,2*v+1,mid+1,end);
}
st[v]=argmax(st[2*v],st[2*v+1]);
}
void ins(int x,int y,int dx,int dy){
int x_=x+dx;
int y_=y+dy;
if(inbounds(x_,y_)&&!used.count({id(x,y),id(x_,y_)})){
diag.push_back(id(x_,y_));
used.insert({id(x,y),id(x_,y_)});
used.insert({id(x_,y_),id(x,y)});
cnt[id(x,y)]--;
update(id(x,y));
cnt[id(x_,y_)]--;
update(id(x_,y_));
}
}
void construct_network(int H, int W, int K) {
h=H;
w=W;
k=K;
used.clear();
memset(cnt,0,sizeof(cnt));
for(int x=0;x<h;x++){
for(int y=0;y<w;y++){
for(int i=0;i<=k;i++){
ins_cnt(x,y,i,k-i);
ins_cnt(x,y,-i,k-i);
ins_cnt(x,y,i,-k+i);
ins_cnt(x,y,-i,-k+i);
}
}
}
build();
while(cnt[st[1]]>0){
//x*w+y=st[1]
int x=st[1]/w;
int y=st[1]%w;
diag.clear();
for(int i=0;i<=k;i++){
ins(x,y,i,k-i);
ins(x,y,-i,k-i);
ins(x,y,i,-k+i);
ins(x,y,-i,-k+i);
}
if(diag.size()>0){
int ans_or=add_or(diag);
int ans_and=add_and({id(x,y),ans_or});
answers.push_back(ans_and);
}
}
add_or(answers);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1079 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
844 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |