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> h_or, w_or;
for(int i = 0; i < h; i++){
vector<int> temp;
for(int j = 0; j < w; j++) temp.pb(cell(i, j));
h_or.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));
w_or.pb(add_or(temp));
}
vector<int> hk(h+w+1, -1), wk(h+w+1, -1);
for(int i = 0; i < h; i++) for(int j = i; j < h; j++){
int x = -1;
if(i == j){
vector<int> temp;
for(int jj = 0; jj < w; jj++) temp.pb(cell(i, jj));
x = add_and({add_not(add_xor(temp)), h_or[i]});
}
else{
x = add_and({h_or[i], h_or[j]});
}
int d = j-i;
if(hk[d] == -1) hk[d] = x;
else hk[d] = add_or({hk[d], x});
}
for(int i = 0; i < w; i++) for(int j = i; j < w; j++){
int x = -1;
if(i == j){
vector<int> temp;
for(int jj = 0; jj < h; jj++) temp.pb(cell(jj, i));
x = add_and({add_not(add_xor(temp)), w_or[i]});
}
else{
x = add_and({w_or[i], w_or[j]});
}
int d = j-i;
if(wk[d] == -1) wk[d] = x;
else wk[d] = add_or({wk[d], x});
}
vector<int> sth;
for(int i = 0; i <= k; i++){
if(hk[i] == -1 || wk[k-i] == -1) continue;
sth.pb(add_and({hk[i], wk[k-i]}));
}
if(sth.empty()) add_and({0, add_not(0)});
else add_or(sth);
}
# | 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... |