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 ad push_back
using namespace std;
const int N = 250;
int n, m, i1;
int tox[N], col[N];
int l1, r1, l2, r2;
int mk, zro;
int ka[N], ka1[N];
void construct_network(int H, int W, int k)
{
n = H, m = W;
for (int i = 0; i < n; i++)
{
vector <int> p;
for (int j = 0; j < m; j++)
p.ad(i * m + j);
if(i) p.ad(tox[i - 1]);
tox[i] = add_xor(p);
}
for (int i = 0; i < m; i++)
{
vector <int> p;
for(int j = 0; j < n; j++)
p.ad(j * m + i);
if(i) p.ad(col[i - 1]);
col[i] = add_xor(p);
}
i1 = col[m - 1] + 1;
int l;
l = 3;
for (int i = 0; i < n; i++)
{
vector <int> p;
if(i == 0)
{
p.ad(tox[i]);
add_or(p);
p.clear(), p.ad(tox[n - 1]);
for(int j = 0; j < l - 1; j++) add_or(p);
i1 += l;
}
else
{
p.ad(tox[i]);
add_or(p);
p.clear();
i1++;
for(int j = 0; j < l - 1; j++)
{
p.clear();
p.ad(i1 - 1);
p.ad(i1 - l - 1);
add_and(p);
i1++;
}
for(int j = 0; j < l; j++)
{
p.clear();
p.ad(i1 - l);
p.ad(i1 - l * 2);
add_xor(p);
i1++;
}
p.clear();
p.ad(col[m - 1]);
if(i == (1 << l) - 3) add_or(p), l++, i1++;
}
if(i == n - 1)
{
l1 = i1 - l;
r1 = i1 - 1;
}
}
l = 3;
for (int i = 0; i < m; i++)
{
vector <int> p;
if(i == 0)
{
p.ad(col[i]);
add_or(p);
p.clear(), p.ad(col[m - 1]);
for(int j = 0; j < l - 1; j++) add_or(p);
i1 += l;
}
else
{
//cout << i1 << endl;
p.clear();
p.ad(col[i]);
add_or(p);
i1++;
for(int j = 0; j < l - 1; j++)
{
p.clear();
p.ad(i1 - 1);
p.ad(i1 - l - 1);
add_and(p);
i1++;
}
for(int j = 0; j < l; j++)
{
p.clear();
p.ad(i1 - l);
p.ad(i1 - l * 2);
add_xor(p);
i1++;
}
p.clear();
p.ad(col[m - 1]);
if(i == (1 << l) - 3) add_or(p), l++, i1++;
}
if(i == m - 1)
{
l2 = i1 - l;
r2 = i1 - 1;
}
}
//cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
vector <int> p;
zro = col[m - 1];
for (int i = 0; i < n; i++) p.ad(tox[i]);
for (int i = 0; i < m; i++) p.ad(col[i]);
mk = add_or(p);
i1 = mk + 1;
l = 3;
for (int i = 0; i < n; i++) if(i == (1 << l) - 3) l++;
for (int i = 0; i < n; i++)
{
//if(i == (1 << l) - 3) l++;
for(int j = 0; j < l; j++)
{
p.clear();
p.ad(l1 + j);
if(i & (1 << j)) p.ad(mk);
else p.ad(zro);
add_xor(p);
i1++;
}
p.clear();
for(int j = 0; j < l; j++)
p.ad(i1 - j - 1);
ka[i] = add_or(p);
i1++;
}
l = 3;
for (int i = 0; i < m; i++) if(i == (1 << l) - 3) l++;
for (int i = 0; i < m; i++)
{
//if(i == (1 << l) - 3) l++;
for(int j = 0; j < l; j++)
{
p.clear();
p.ad(l2 + j);
if(i & (1 << j)) p.ad(mk);
else p.ad(zro);
add_xor(p);
i1++;
}
p.clear();
for(int j = 0; j < l; j++)
p.ad(i1 - j - 1);
ka1[i] = add_or(p);
i1++;
}
int ii = -1;
for (int i = 0; i <= k; i++)
{
if(n <= i || k - i >= m) continue;
if(ii == -1) ii = i1;
p.clear();
p.ad(ka[i]);
p.ad(ka1[k - i]);
add_or(p);
i1++;
}
p.clear();
for (int i = ii; i < i1; i++)
p.ad(i);
add_xor(p);
i1++;
int sm = p.size();
if(sm % 2 == 1) add_not(i1 - 1);
}
# | 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... |