This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
const int N = 401;
int H, W, K;
vi getdia1(int r, int c) {
vi cells;
for(;;) {
cells.push_back(r * W + c);
r--, c++;
if(r < 0 || c >= W) break;
}
return cells;
}
vi getdia2(int r, int c) {
vi cells;
for(;;) {
cells.push_back(r * W + c);
r--, c--;
if(r < 0 || c < 0) break;
}
return cells;
}
int dia1[N + N], dia2[N + N];
int prefix1[N + N], prefix2[N + N];
void construct_network(int h, int w, int k) {
H = h, W = w, K = k;
for(int i = 0; i < h; i++) {
vi cells = getdia1(i, 0);
dia1[i] = add_xor(cells);
}
for(int j = 1; j < w; j++) {
vi cells = getdia1(h - 1, j);
dia1[h - 1 + j] = add_xor(cells);
}
for(int i = 0; i < h + w - 1; i++) {
vi tmp;
for(int j = 0; j <= i; j++) tmp.push_back(dia1[j]);
prefix1[i] = add_xor(tmp);
}
vi KKdifres, Kdifres;
for(int i = 0; i + K < h + w - 1; i++) {
vi tmp(2);
tmp[0] = prefix1[i];
tmp[1] = prefix1[i + K];
KKdifres.push_back(add_and(tmp));
}
for(int i = 0; i + K - 1 < h + w - 1; i++) {
vi tmp(2);
tmp[0] = prefix1[i];
tmp[1] = prefix1[i + K - 1];
Kdifres.push_back(add_and(tmp));
}
int greaterthanK1, greaterthanKK1;
greaterthanK1 = add_or(Kdifres);
greaterthanKK1 = add_or(KKdifres);
for(int i = 0; i < h; i++) {
vi cells = getdia2(i, w - 1);
dia2[i - w + 1 + w] = add_xor(cells);
}
for(int j = w - 2; j >= 0; j--) {
vi cells = getdia2(h - 1, j);
dia2[h - 1 - j + w] = add_xor(cells);
}
for(int i = 1; i <= h - 1 + w; i++) {
vi tmp;
for(int j = 1; j <= i; j++) tmp.push_back(dia2[j]);
prefix2[i] = add_xor(tmp);
}
KKdifres.clear(); Kdifres.clear();
for(int i = 1; i + K <= h + w - 1; i++) {
vi tmp(2);
tmp[0] = prefix2[i];
tmp[1] = prefix2[i + K];
KKdifres.push_back(add_and(tmp));
}
for(int i = 1; i + K - 1 <= h + w - 1; i++) {
vi tmp(2);
tmp[0] = prefix2[i];
tmp[1] = prefix2[i + K - 1];
Kdifres.push_back(add_and(tmp));
}
int greaterthanK2, greaterthanKK2;
greaterthanK2 = add_or(Kdifres);
greaterthanKK2 = add_or(KKdifres);
vi tmp(2);
tmp[0] = greaterthanKK1, tmp[1] = greaterthanKK2;
int wrong = add_or(tmp);
tmp[0] = greaterthanK1, tmp[1] = greaterthanK2;
int ok = add_or(tmp);
int notwrong = add_not(wrong);
tmp[0] = ok, tmp[1] = notwrong;
add_and(tmp);
}
# | 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... |