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 sz(x) (int)x.size()
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define lowb(x) (x&(-x))
#define ALL(_x) _x.begin(),_x.end()
#define pii pair<int,int>
#define f first
#define s second
#define SORT_UNIQUE(x) sort(ALL(x)),x.erase(unique(ALL(x)),x.end())
const int maxn=1e3+5;
#define ll long long
vector<int> a[maxn],b[maxn];
int n,m;
int aa[maxn],bb[maxn];
int pa[maxn],pb[maxn];
int xa,xb;
int leq(int x){
vector<int> az,bz;
REP(i,n+m-1){
if(i>=x+1) az.pb(add_and({aa[i],add_not(pa[i-x-1]),pa[i-1]})),bz.pb(add_and({bb[i],add_not(pb[i-x-1]),pb[i-1]}));
else if(i) az.pb(add_and({aa[i],pa[i-1]})),bz.pb(add_and({bb[i],pb[i-1]}));
az.pb(add_and({xa,aa[i]})),bz.pb(add_and({xb,bb[i]}));
}
return add_and({add_or(az),add_or(bz)});
}
void construct_network(int H, int W, int K) {
n=H,m=W;
REP(i,n){
REP(j,m){
a[i+j].pb(i*m+j);
b[i-j+m-1].pb(i*m+j);
}
}
REP(i,n+m-1){
aa[i]=add_or(a[i]);
bb[i]=add_or(b[i]);
}
xa=aa[0],xb=bb[0];
pa[0]=aa[0],pb[0]=bb[0];
REP1(i,n+m-2){
pa[i]=add_or({pa[i-1],aa[i]});
pb[i]=add_or({pb[i-1],bb[i]});
xa=add_xor({xa,aa[i]}),xb=add_xor({xb,bb[i]});
}
if(K==1){
leq(K);
return;
}
int a=leq(K),b=leq(K-1);
add_and({a,add_not(b)});
}
# | 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... |