이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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) + 1) {
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
// cout << max(k - w + 1, 0) << " " << min(h - 1, k) << " " << max(k - h + 1, 0) << " " << min(w - 1, k) << endl;
vi sep_by_col;
LI(i, 0, max(k - w + 1, 0)) sep_by_col.pb(-1);
LI(i, max(k - w + 1, 0), min(h - 1, k) + 1) {
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) + 1) {
assert(sep_by_row[i] != -1);
assert(sep_by_col[k - i] != -1);
final_to_or.pb(add_and({sep_by_row[i], sep_by_col[k - i]}));
}
add_or(final_to_or);
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... |