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;
void construct_network(int H, int W, int K) {
vector<int> Ns;
int empl=H*W-1;
if (H>30 || W>30)
{
int i=0, j=0;
vector<int> possibles;
int act=i*W+j;
for (int k = 0; k < H; ++k)
{
for (int l = 0; l < W; ++l)
{
if (abs(k-i)+abs(l-j)==K && k*W+l>=act)
{
possibles.push_back(k*W+l);
}
}
}
if (!possibles.size()) {
return;
}
if (possibles.size()==1)
{
add_and({possibles[0], i*W+j});
empl++;
}
else
{
add_xor(possibles);
empl++;
add_and({empl, i*W+j});
empl++;
}
return;
}
if (K==1)
{
int l=0, r=H*W-1;
while(l<r) {
int mid=(l+r)/2;
vector<int> temp;
for (int i = l; i <= mid; ++i)
{
temp.push_back(i);
}
if (add_or(temp)) {
r=mid;
} else {
l=mid+1;
}
}
int act=l;
vector<int> solution;
int gd=act%W;
if (act-W>=0) solution.push_back(act-W);
if (act+W<=H*W-1) solution.push_back(act+W);
if (gd-1>=0) solution.push_back(act-1);
if (gd+1<=W) solution.push_back(act+1);
add_or(solution);
return;
}
for (int i = 0; i < H; ++i)
{
for (int j = 0; j < W; ++j)
{
vector<int> possibles;
int act=i*W+j;
for (int k = 0; k < H; ++k)
{
for (int l = 0; l < W; ++l)
{
if (abs(k-i)+abs(l-j)==K && k*W+l>=act)
{
possibles.push_back(k*W+l);
}
}
}
if (!possibles.size()) continue;
if (possibles.size()==1)
{
add_and({possibles[0], i*W+j});
empl++;
}
else
{
add_xor(possibles);
empl++;
add_and({empl, i*W+j});
empl++;
}
Ns.push_back(empl);
}
}
add_or(Ns);
return;
}
# | 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... |