This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Vision Program
*/
#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
int height, width;
int arrayPos(int c, int r)
{
return c * width + r;
}
bool inside(int c, int r)
{
return c >= 0 && c < height && r >= 0 && r < width;
}
void construct_network(int H, int W, int K)
{
height = H; width = W;
vector<int> instructions;
for (int c = 0; c < H; c++)
{
for (int r = 0; r < W; r++)
{
if (r + K < W)
instructions.push_back(add_and({arrayPos(c, r), arrayPos(c, r + K)}));
if (c + K < H)
instructions.push_back(add_and({arrayPos(c, r), arrayPos(c + K, r)}));
for (int j = 1; j < K; j++)
{
if (inside(c + j, r - (K - j)))
instructions.push_back(add_and({arrayPos(c, r), arrayPos(c + j, r - (K - j))}));
if (inside(c + j, r + (K - j)))
instructions.push_back(add_and({arrayPos(c, r), arrayPos(c + j, r + (K - j))}));
}
}
}
add_or(instructions);
}
/*
--Sample testcase--
vector<int> Ns;
Ns = {0, 5};
int a = add_and(Ns);
Ns = {3, 2};
int b = add_and(Ns);
Ns = {a, b};
add_or(Ns);
---
2 3 1
0 0
1 2
-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... |