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 "grader.cpp"
#include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
using namespace std;
void construct_network(int H, int W, int K) {
vector<int> a,b;
for(int i=0;i<H;i++){
vector<int> v;
for(int j=0;j<W;j++){
v.pb(i*W+j);
}
if(add_or(v)) a.pb(i);
}
for(int j=0;j<W;j++){
vector<int> v;
for(int i=0;i<H;i++){
v.pb(i*W+j);
}
if(add_or(v)) b.pb(j);
}
int x1=-1,x2=-1,y1=-1,y2=-1;
if(a.size()==2){
int l=0,r=W-1;
while(l<r){
int md=(l+r)/2;
vector<int> v;
for(int i=l;i<=md;i++){
v.pb(a[0]*W+i);
}
if(add_or(v)) r=md;
else l=md+1;
}
x1=a[0],y1=l;
l=0,r=W-1;
while(l<r){
int md=(l+r)/2;
vector<int> v;
for(int i=l;i<=md;i++){
v.pb(a[1]*W+i);
}
if(add_or(v)) r=md;
else l=md+1;
}
x2=a[1],y2=l;
}
else if(b.size()==2){
a=b;
int l=0,r=H-1;
while(l<r){
int md=(l+r)/2;
vector<int> v;
for(int i=l;i<=md;i++){
v.pb(i*W+a[0]);
}
if(add_or(v)) r=md;
else l=md+1;
}
x1=l,y1=a[0];
l=0,r=H-1;
while(l<r){
int md=(l+r)/2;
vector<int> v;
for(int i=l;i<=md;i++){
v.pb(i*W+a[1]);
}
if(add_or(v)) r=md;
else l=md+1;
}
x2=l,y2=a[1];
}
if(x1==-1) assert(0);
if(abs(x2-x1)+abs(y2-y1)==K) add_or({x1*W+y1});
else add_not({x1*W+y1});
}
# | 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... |