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 X first
#define Y second
#define MP make_pair
#define ll long long
using namespace std;
const int N = 300;
void build(int n, int (&arr)[N], const int (&mem)[N]){
for(int it = 0;(1 << it) < n;it++){
vector< int > fin;
for(int i1 = 0;i1 + 1 < n;i1++){
vector<int> tmp;
for(int i2 = i1 + 1;i2 < n;i2++){
if(((i2 - i1) >> it) & 1){
tmp.push_back(mem[i2]);
}
}
if(tmp.empty()) continue;
int v = add_xor(tmp);
v = add_and({mem[i1], v});
fin.push_back(v);
}
arr[it] = add_or(fin);
}
}
int prep(int len, int n, const int (&arr)[N]){
int v;
if(len == 0){
vector<int> tmp;
for(int i = 0;i < n;i++){
tmp.push_back(arr[i]);
}
v = add_xor(tmp);
}
else{
vector<int> tmp1, tmp2;
for(int i = 0;(1 << i) < n;i++){
if((len >> i) & 1) tmp1.push_back(arr[i]);
else tmp2.push_back(arr[i]);
}
if(tmp1.empty()){
v = add_not(add_or(tmp2));
}
else if(tmp2.empty()){
v = add_and(tmp1);
}
else{
v = add_and({add_and(tmp1), add_not(add_or(tmp2))});
}
}
return v;
}
int isRow[N], isCol[N];
int bRow[N], bCol[N];
void construct_network(int H, int W, int K) {
for(int i = 0;i < H;i++){
vector<int> tmp;
for(int j = 0;j < W;j++){
tmp.push_back(W * i + j);
}
isRow[i] = add_or(tmp);
}
for(int j = 0;j < W;j++){
vector<int> tmp;
for(int i = 0;i < H;i++){
tmp.push_back(W * i + j);
}
isCol[j] = add_or(tmp);
}
build(H, bRow, isRow);
build(W, bCol, isCol);
vector< int > fin;
for(int i = 0;i < H;i++){
for(int j = 0;j < W;j++){
if(i + j == K){
int x = prep(i, H, i == 0 ? isRow: bRow);
int y = prep(j, W, j == 0 ? isCol: bCol);
fin.push_back(add_and({x, y}));
}
}
}
add_or(fin);
}
# | 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... |