This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
typedef long long ll;
const int NM_MAX = 202;
int add_and (vector <int> Ns);
int add_or (vector <int> Ns);
int add_xor (vector <int> Ns);
int add_not (int N);
int N, M;
int getKey (int a, int b)
{
return (a - 1) * M + b - 1;
}
int diag1[NM_MAX * 2], diag2[NM_MAX * 2];
int dkdiag1[NM_MAX * 2], dkdiag2[NM_MAX * 2];
int dlessdiag1[NM_MAX * 2], dlessdiag2[NM_MAX * 2];
int diag1Equal, diag2Equal;
int diag1Less, diag2Less;
void construct_network (int n, int m, int k)
{
N = n;
M = m;
vector <int> q;
q.clear();
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
q.push_back(getKey(i, j));
int alwaysFalse = add_xor(q);
/// ====== DIAGONALS ======
int curr;
/// 5 6 7 8
/// 4 5 6 7
/// 3 4 5 6
/// 2 3 4 5
/// 1 2 3 4
curr = 0;
for(int is = n; is >= 1; is--)
{
curr++;
q.clear();
for(int i = is, j = 1; i <= n && j <= m; i++, j++)
q.push_back(getKey(i, j));
diag1[curr] = add_or(q);
}
for(int js = 2; js <= m; js++)
{
curr++;
q.clear();
for(int i = 1, j = js; i <= n && j <= m; i++, j++)
q.push_back(getKey(i, j));
diag1[curr] = add_or(q);
}
/// 1 2 3 4
/// 2 3 4 5
/// 3 4 5 6
/// 4 5 6 7
/// 5 6 7 8
curr = 0;
for(int js = 1; js <= m; js++)
{
curr++;
q.clear();
for(int i = 1, j = js; i <= n && j >= 1; i++, j--)
q.push_back(getKey(i, j));
diag2[curr] = add_or(q);
}
for(int is = 2; is <= n; is++)
{
curr++;
q.clear();
for(int i = is, j = m; i <= n && j >= 1; i++, j--)
q.push_back(getKey(i, j));
diag2[curr] = add_or(q);
}
/// ====== DISTANCE K DIAGONALS ======
for(int d = 1; d + k <= n + m - 1; d++)
{
q.clear();
q.push_back(diag1[d]);
q.push_back(diag1[d + k]);
dkdiag1[d] = add_and(q);
}
for(int d = 1; d + k <= n + m - 1; d++)
{
q.clear();
q.push_back(diag2[d]);
q.push_back(diag2[d + k]);
dkdiag2[d] = add_and(q);
}
/// ====== DISTANCE LESS THAN K DIAGONALS ======
for(int d = 1; d + k <= n + m - 1; d++)
{
q.clear();
for(int l = 1; l < d; l++)
q.push_back(diag1[l]);
for(int r = d + k + 1; r <= n + m - 1; r++)
q.push_back(diag1[r]);
int aux;
if(q.empty() == true)
aux = alwaysFalse;
else
aux = add_and(q);
dlessdiag1[d] = add_not(aux);
}
for(int d = 1; d + k <= n + m - 1; d++)
{
q.clear();
for(int l = 1; l < d; l++)
q.push_back(diag2[l]);
for(int r = d + k + 1; r <= n + m - 1; r++)
q.push_back(diag2[r]);
int aux;
if(q.empty() == true)
aux = alwaysFalse;
else
aux = add_and(q);
dlessdiag2[d] = add_not(aux);
}
/// ====== EQUAL ======
q.clear();
for(int d = 1; d + k <= n + m - 1; d++)
q.push_back(dkdiag1[d]);
diag1Equal = add_or(q);
q.clear();
for(int d = 1; d + k <= n + m - 1; d++)
q.push_back(dkdiag2[d]);
diag2Equal = add_or(q);
/// ====== LESS ======
q.clear();
for(int d = 1; d + k <= n + m - 1; d++)
q.push_back(dlessdiag1[d]);
diag1Less = add_or(q);
q.clear();
for(int d = 1; d + k <= n + m - 1; d++)
q.push_back(dlessdiag2[d]);
diag2Less = add_or(q);
/// ====== FINAL RESULT ======
int case1, case2;
q.clear();
q.push_back(diag1Equal);
q.push_back(diag2Less);
case1 = add_and(q);
q.clear();
q.push_back(diag1Less);
q.push_back(diag2Equal);
case2 = add_and(q);
int answer;
q.clear();
q.push_back(case1);
q.push_back(case2);
answer = add_or(q);
}
Compilation message (stderr)
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:170:9: warning: variable 'answer' set but not used [-Wunused-but-set-variable]
170 | int answer;
| ^~~~~~
# | 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... |