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"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;
#define maxn 205
vector<ll> aks;
ll n,m,k;
ll kod(ll x,ll y){return (x-1)*m+y-1;}
ll zero,one;
ll reshi(vector<vector<ll> > v,ll k){
vector<ll> vor,vxor;
for(auto w : v){
vor.pb(add_or(w));
vxor.pb(add_xor(w));
}
vector<ll> vok;
for(ll i = 0;i+k-1<si(v);i++){
vector<ll> cur;
cur.pb(zero);
for(ll j = i;j<=i+k-1;j++) cur.pb(vor[j]);
ll x = add_or(cur);
cur.clear();
cur.pb(zero);
for(ll j = 1;j<=i+k-1;j++) cur.pb(vxor[j]);
ll y = add_not(add_xor(cur));
cur.clear();
vok.pb(add_and({x,y}));
}
return add_or(vok);
}
ll reshi(ll k){
vector<vector<ll> > diag;
for(ll s = 2;s<=n+m;s++){
vector<ll> v;
for(ll i = 1;i<=n;i++){
ll j = s-i;
if(j>m||j<=0) continue;
v.eb(kod(i,j));
}
diag.pb(v);
}
ll i = reshi(diag,k);
diag.clear();
for(ll s = 1-m;s<=n-1;s++){
vector<ll> v;
for(ll i = 1;i<=n;i++){
ll j = i - s;
if(j>m||j<=0) continue;
v.eb(kod(i,j));
}
diag.pb(v);
}
ll j = reshi(diag,k);
return add_xor({i,j});
}
void construct_network(int H, int W, int K) {
n = H;
m = W;
k = K;
vector<ll> ask;
for(ll i = 0;i<=n*m-1;i++) ask.pb(i);
zero = add_xor(ask);
one = add_not(zero);
ll i = reshi(k+1);
ll j = reshi(k);
j = add_not(j);
add_and({i,j});
}
/**
2 3 3
0 0 1 2
0 2 1 0
**/
# | 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... |