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"
using namespace std;
#define pb push_back
const int N = 405;
int xpy[N], xmy[N], a[N], b[N];
vector<int> pv[N], mv[N], av[N], bv[N], v;
int por1(int x){
for(int i = 2; i * i <= x; i++) if(x % i == 0) return 0;
return 1;
}
void construct_network(int H, int W, int K) {
for(int i = 0; i < H; i++) for(int j = 0; j < W; j++){
pv[i + j].pb(i * W + j);
mv[H - 1 - i + j].pb(i * W + j);
}
for(int i = 0; i <= H + W - 2; i++){
xpy[i] = add_or(pv[i]);
xmy[i] = add_or(mv[i]);
}
for(int i = 0; i <= H + W - 2; i++) for(int j = i + 1; j <= H + W - 2; j++){
int d = j - i;
if(d % K || !por1(d / K)) continue;
vector<int> t(2);
t[0] = xpy[i]; t[1] = xpy[j];
av[j - i].pb(add_and(t));
t[0] = xmy[i]; t[1] = xmy[j];
bv[j - i].pb(add_and(t));
}
for(int i = 1; i <= H + W - 2; i++){
if(av[i].empty()) continue;
a[i] = add_or(av[i]);
b[i] = add_or(bv[i]);
}
for(int i = K + 1; i <= H + W - 2; i++){
if(!a[i]) continue;
v.push_back(a[i]);
v.push_back(b[i]);
}
vector<int> t(2);
t[0] = a[K]; t[1] = b[K];
v.push_back(add_not(add_or(t)));
add_not(add_or(v));
}
# | 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... |