This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#if defined(ONPC) && !defined(_GLIBCXX_ASSERTIONS)
#define _GLIBCXX_ASSERTIONS
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#ifdef ONPC
#define cerr cout
#include "t_debug.cpp"
#else
#define debug(...) 42
#endif
#define allit(a) (a).begin(), (a).end()
#define sz(a) ((int) (a).size())
#include "vision.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
namespace pd = __gnu_pbds;
template<typename K>
using ordered_set = pd::tree<K, pd::null_type, less<int>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>;
template<typename... T>
using gp_hash_table = pd::gp_hash_table<T...>;//simple using statement gives warnings
const int INF = 1e9;
const ll INFL = 1e18;
const int N = 1e5;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
#define ENC(i,j) ((i) * m + (j))
void construct_network(int n, int m, int dist) {
if (n * m * 4 + dist * 4 < 10000) {
vi pos;
char added[n*m][n*m];
memset(added, 0, sizeof(added));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
for (int ii = 0; ii < n; ii++) {
for (int jj = 0; jj < m; jj++) {
int a = ENC(i, j);
int b = ENC(ii, jj);
if (a > b) swap(a, b);
if (abs(ii-i) + abs(jj-j) == dist && !added[a][b]) {
pos.push_back(add_and({a, b}));
added[a][b] = 1;
}
}
}
}
}
for (int i = 1, prev = pos[0]; i < sz(pos); i++) {
prev = add_or({prev, pos[i]});
}
}
else if (dist == 1 && (n * m) * 4 < 10000) {
vi pos;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i) pos.push_back(add_and({ENC(i, j), ENC(i-1, j)}));
if (j) pos.push_back(add_and({ENC(i, j), ENC(i, j-1)}));
}
}
debug(pos);
for (int i = 1, prev = pos.front(); i < sz(pos); i++) {
prev = add_or({prev, pos[i]});
}
}
else {
int prev = -1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i + j == dist) {
if (prev == -1) prev = i*m + j;
else prev = add_or({prev, i*m + j});
}
}
}
add_and({prev, prev});
}
}
#undef ENC
Compilation message (stderr)
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:11:24: warning: statement has no effect [-Wunused-value]
11 | #define debug(...) 42
| ^~
vision.cpp:65:9: note: in expansion of macro 'debug'
65 | debug(pos);
| ^~~~~
# | 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... |