// AM+DG
/*
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
#define L(i, varmn, varmx) for(ll i = varmn; i < varmx; i++)
#define LR(i, varmx, varmn) for(ll i = varmx; i > varmn; i--)
#define LI(i, varmn, varmx) for(int i = varmn; i < varmx; i++)
#define LIR(i, varmx, varmn) for(int i = varmx; i > varmn; i--)
#define pb push_back
#include "vision.h"
int cellnum(int r, int c, int W) {
return r * W + c;
}
void construct_network(int h, int w, int k) {
// Falsy/truthy values, may help!
int falsy = add_xor({0, 0});
int truthy = add_not(falsy);
// Row/col stuff
vi row_has;
LI(i, 0, h) {
vi all_in_row;
LI(j, 0, w) {
all_in_row.pb(cellnum(i, j, w));
}
row_has.pb(add_or(all_in_row));
}
vi col_has;
LI(i, 0, w) {
vi all_in_col;
LI(j, 0, h) all_in_col.pb(cellnum(j, i, w));
col_has.pb(add_or(all_in_col));
}
// int row_is_same = add_xor(row_has);
// int col_is_same = add_xor(col_has);
// r + c = k
// r = k - c
// 0 <= r <= w - 1;
// 0 <= k - c <= w - 1;
// k >= c >= k - w + 1;
// k >= r >= k - h + 1;
// Iterate through rows
vi sep_by_row;
LI(i, 0, max(k - h + 1, 0)) sep_by_row.pb(-1);
LI(i, max(k - h + 1, 0), min(w - 1, k)) {
vi to_or;
LI(j, 0, w - i) {
to_or.pb(add_and(row_has[j], row_has[j + i]));
}
sep_by_row.pb(add_or(to_or));
}
// Iterate through columns
vi sep_by_col;
LI(i, 0, max(k - w + 1, 0)) sep_by_row.pb(-1);
LI(i, max(k - w + 1, 0), min(h - 1, k)) {
vi to_or;
LI(j, 0, h - i) {
to_or.pb(add_and(col_has[j], col_has[j + i]));
}
sep_by_col.pb(add_or(to_or));
}
// ORing the possible separations
vi final_to_or;
LI(i, max(k - h + 1, 0), min(w - 1, k)) {
final_to_or.pb(add_and(sep_by_row[i], sep_by_col[k - i]));
}
add_or(final_to_or);
return;
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:65:56: error: could not convert 'row_has.std::vector<int>::operator[](((std::vector<int>::size_type)j))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
65 | to_or.pb(add_and(row_has[j], row_has[j + i]));
| ^
| |
| __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
vision.cpp:76:56: error: could not convert 'col_has.std::vector<int>::operator[](((std::vector<int>::size_type)j))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
76 | to_or.pb(add_and(col_has[j], col_has[j + i]));
| ^
| |
| __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
vision.cpp:85:64: error: could not convert 'sep_by_row.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
85 | final_to_or.pb(add_and(sep_by_row[i], sep_by_col[k - i]));
| ^
| |
| __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}
vision.cpp:31:9: warning: unused variable 'truthy' [-Wunused-variable]
31 | int truthy = add_not(falsy);
| ^~~~~~