# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069895 | andrei_iorgulescu | Vision Program (IOI19_vision) | C++14 | 1 ms | 1080 KiB |
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 <bits/stdc++.h>
#include "vision.h"
#warning That's not FB, that's my FB
using namespace std;
int h, w, k;
int sure_0, sure_1;
int cond1()
{
if (k >= h - 1)
{
return add_or({sure_1});
}
vector<int> vlin(h);
for (int i = 0; i < h; i++)
{
vector<int> ps;
for (int j = 0; j < w; j++)
ps.push_back(w * i + j);
vlin[i] = add_or(ps);
}
vector<int> cns;
for (int i = 0; i < h; i++)
{
vector<int> ur;
for (int j = 1; j <= k; j++)
if (i + j < h)
ur.push_back(vlin[i + j]);
int pp = add_or(ur);
cns.push_back(add_and({vlin[i], pp}));
}
int rr = add_or(cns);
cns.clear();
for (int i = 0; i < h; i++)
cns.push_back(vlin[i]);
int rrr = add_xor(cns);
int rrrr = add_or({rr,rrr});
return rrrr;
}
int cond2()
{
if (k >= w - 1)
{
return add_or({sure_1});
}
vector<int> vlin(w);
for (int j = 0; j < w; j++)
{
vector<int> ps;
for (int i = 0; i < h; i++)
ps.push_back(w * i + j);
vlin[j] = add_or(ps);
}
vector<int> cns;
for (int i = 0; i < w; i++)
{
vector<int> ur;
for (int j = 1; j <= k; j++)
if (i + j < w)
ur.push_back(vlin[i + j]);
int pp = add_or(ur);
cns.push_back(add_and({vlin[i], pp}));
}
int rr = add_or(cns);
cns.clear();
for (int i = 0; i < w; i++)
cns.push_back(vlin[i]);
int rrr = add_xor(cns);
int rrrr = add_or({rr,rrr});
return rrrr;
}
int cond3()
{
vector<vector<int>> diag(h + w - 1);
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
diag[i + j].push_back(w * i + j);
}
}
vector<int> cdiag(h + w - 1);
for (int i = 0; i < h + w - 1; i++)
cdiag[i] = add_or(diag[i]);
vector<int> ff;
for (int i = 0; i + k < h + w - 1; i++)
ff.push_back(add_and({cdiag[i], cdiag[i + k]}));
int lmao = add_or(ff);
return lmao;
}
int cond4()
{
int ofs = w - 1;
vector<vector<int>> diag(h + w - 1);
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
diag[i - j + ofs].push_back(w * i + j);
}
}
vector<int> cdiag(h + w - 1);
for (int i = 0; i < h + w - 1; i++)
cdiag[i] = add_or(diag[i]);
vector<int> ff;
for (int i = 0; i + k < h + w - 1; i++)
ff.push_back(add_and({cdiag[i], cdiag[i + k]}));
int lmao = add_or(ff);
return lmao;
}
void construct_network(int H, int W, int K)
{
if (H * W == 2)
{
if (K == 1)
{
add_or({0});
return;
}
else
{
add_not(0);
return;
}
}
vector<int> tot;
for (int i = 0; i < H * W; i++)
tot.push_back(i);
sure_0 = add_and(tot);
sure_1 = add_or(tot);
h = H, w = W, k = K;
int pos1 = cond1();
int pos2 = cond2();
int pos3 = cond3();
int pos4 = cond4();
int pos5 = add_or({pos3, pos4});
int fin = add_and({pos1, pos2, pos5});
//cout << pos1 << ' ' << pos2 << ' ' << pos3 << ' ' << pos4 << ' ' << pos5 << endl;
//cout << "ye" << endl;
return;
}
/**
Conditie de echivalenta:
C1: delta_lin <= k
C2: delta_col <= k
C3: delta_dp = k sau C4: delta_ds = k
Practic verific C1, C2, C3, C4 si pun (C1 & C2 & (C3 | C4))
**/
Compilation message (stderr)
# | 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... |