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>
using namespace std;
#define forn(i,n) for(int i=0; i<n; ++i)
#define pb push_back
int zero, one;
vector<int> add(vector<int> f, vector<int> s) {
int n=9;
int temp=zero;
vector<int> ret;
forn(i,n) {
ret.pb(add_xor({temp,f[i],s[i]}));
temp = add_or({add_and({f[i],s[i]}), add_and({temp,add_or({f[i],s[i]})})});
}
return ret;
}
void construct_network(int n, int m, int k) {
if (n*m==2) {
add_or({0,1});
return;
}
if (1) {
vector<int> v;
forn(i,n) forn(j,m) v.pb(i*m+j);
zero=add_and(v);
one=add_not(zero);
}
vector<int> row_xor, col_xor;
forn(j,m) {
vector<int> v;
forn(i,n) v.pb(i*m+j);
col_xor.pb(add_xor(v));
}
forn(i,n) {
vector<int> v;
forn(j,m) v.pb(i*m+j);
row_xor.pb(add_xor(v));
}
vector<int> rf,rs,cf,cs;
vector<int> row_pr = {zero};
vector<int> col_pr = {zero};
forn(i,n) row_pr.pb(add_xor({row_pr[i],row_xor[i]}));
forn(i,m) col_pr.pb(add_xor({col_pr[i],col_xor[i]}));
int t=9;
vector<vector<int>> z(t,{zero});
forn(i,n) {
forn(j,t) {
if ((i>>j)&1) {
z[j].pb(add_and({row_pr[i+1],row_xor[i]}));
}
}
}
forn(i,t) {
rf.pb(add_or(z[i]));
z[i]={zero};
}
forn(i,n) {
forn(j,t) {
if ((i>>j)&1) {
z[j].pb(add_and({add_not(row_pr[i+1]),row_xor[i]}));
}
}
}
forn(i,t) {
rs.pb(add_or(z[i]));
z[i]={zero};
}
forn(i,m) {
forn(j,t) {
if ((i>>j)&1) {
z[j].pb(add_and({col_pr[i+1],col_xor[i]}));
}
}
}
forn(i,t) {
cf.pb(add_or(z[i]));
z[i]={zero};
}
forn(i,m) {
forn(j,t) {
if ((i>>j)&1) {
z[j].pb(add_and({add_not(col_pr[i+1]),col_xor[i]}));
}
}
}
forn(i,t) {
cs.pb(add_or(z[i]));
z[i]={zero};
}
auto sumf = add(rf,cf);
auto sums = add(rs,cs);
vector<int> kb;
forn(i,t) {
if ((k>>i)&1) kb.pb(one);
else kb.pb(zero);
}
auto qq = add(sumf,kb);
vector<int> zz;
forn(i,t) {
zz.pb(add_xor({qq[i],sums[i]}));
}
add_not(add_or(zz));
}
# | 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... |