// 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
// 1 <= r <= w - 1;
// 1 <= k - c <= w - 1;
// k - 1 >= c >= k - w + 1;
// k - 1 >= 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) {
LI(i, 0, h - 1) {
vi to_or;
LI(j, 0, h - 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) {
LI(i, 0, w - 1) {
vi to_or;
LI(j, 0, w - 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, 1), min(w - 1, k - 1) + 1) {
assert(sep_by_col[i] != -1);
assert(sep_by_row[k - i] != -1);
final_to_or.pb(add_and({sep_by_col[i], sep_by_row[k - i]}));
}
if(k < h) {
final_to_or.pb(add_and({sep_by_row[k], col_is_same}));
}
if(k < w) {
final_to_or.pb(add_and({row_is_same, sep_by_col[k]}));
}
// cout << final_to_or.size() << endl;
add_or(final_to_or);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid index |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid index |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid index |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid index |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1240 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
432 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1328 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid index |
3 |
Halted |
0 ms |
0 KB |
- |