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 construct_network(int _h, int _w, int _k){
h = _h, w = _w, k = _k;
vector<int> diag1_or(h+w-1), diag2_or(h+w-1), diag1_xor(h+w-1), diag2_xor(h+w-1);
vector<vector<int>> diag1(h+w-1), diag2(h+w-1);
for(int i = 0; i < h; i++) for(int j = 0; j < w; j++){
diag1[i+j].pb(cell(i, j));
diag2[w-1+i-j].pb(cell(i, j));
}
for(int i = 0; i < h+w-1; i++)
diag1_or[i] = add_or(diag1[i]), diag1_xor[i] = add_xor(diag1[i]),
diag2_or[i] = add_or(diag2[i]), diag2_xor[i] = add_xor(diag2[i]);
int zero = add_and({0, add_not(0)});
auto get = [&](int K){
int a = zero, b = zero;
for(int i = 0; i < h+w-1; i++)
a = add_or({a, add_and({diag1_or[i], add_not(diag1_xor[i])})});
for(int i = 0; i < h+w-1; i++)
b = add_or({b, add_and({diag2_or[i], add_not(diag2_xor[i])})});
for(int i = 0; i < h+w-1; i++){
vector<int> temp;
for(int j = 0; j < K && i+j < h+w-1; j++) temp.pb(diag1_or[i+j]);
a = add_or({a, add_and({add_or(temp), add_not(add_xor(temp))})});
}
for(int i = 0; i < h+w-1; i++){
vector<int> temp;
for(int j = 0; j < K && i+j < h+w-1; j++) temp.pb(diag2_or[i+j]);
b = add_or({b, add_and({add_or(temp), add_not(add_xor(temp))})});
}
return add_and({a, b});
};
add_and({get(k+1), add_not(get(k))});
}
# | 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... |