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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int h, w, k;
int cell(int i, int j){
return i*w+j;
}
void p8(){
vector <int> v;
for(int i = 0; i <= k; i++){
int j = k-i;
if(i >= h || j >= w) continue;
v.pb(add_and({0, cell(i, j)}));
}
add_or(v);
}
void construct_network(int H, int W, int K){
h = H, w = W, k = K;
if(k > 1 && max(h, w) > 30){
p8();
return;
}
vector<int> hh, ww;
for(int i = 0; i < h; i++){
vector<int> temp;
for(int j = 0; j < w; j++) temp.pb({cell(i, j)});
hh.pb(add_or(temp));
}
for(int j = 0; j < w; j++){
vector<int> temp;
for(int i = 0; i < h; i++) temp.pb({cell(i, j)});
ww.pb(add_or(temp));
}
vector<int> hw = hh; hw.insert(hw.end(), ww.begin(), ww.end());
int in1 = add_xor(hw);
vector<int> v;
for(int kk = 0; kk <= k; kk++){
int a = kk, b = k-kk;
if(a >= h || b >= w) continue;
vector<int> sh, sw;
for(int i = 0; i < h-a; i++) sh.pb(add_and({hh[i], hh[i+a]}));
for(int i = 0; i < w-b; i++) sw.pb(add_and({ww[i], ww[i+b]}));
if(a == 0) v.pb(add_and({in1, add_or(sw)}));
else if(b == 0) v.pb(add_and({add_or(sh), in1}));
else v.pb(add_and({add_or(sh), add_or(sw)}));
}
add_or(v);
}
# | 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... |