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>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
void construct_network(int n, int m, int k) {
if(k==n+m-2) {
add_and({0, n*m-1});
add_and({(n-1)*m, m-1});
add_or({n*m, n*m+1});
return;
}
int sz = n*m;
vector<int> diag(n+m-1), adiag(n+m-1);
vector<vector<int>> diag_l(n+m-1), adiag_l(n+m-1);
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
diag_l[i+j].push_back(i*m+j);
adiag_l[n-i-1+j].push_back(i*m+j);
}
}
for(int i = 0; i < n+m-1; i++) {
add_or(diag_l[i]);
diag[i] = sz++;
}
for(int i = 0; i < n+m-1; i++) {
add_or(adiag_l[i]);
adiag[i] = sz++;
}
int d1 = -1;
for(int i = 0; i+k < n+m-1; i++) {
add_and({diag[i], diag[i+k]});sz++;
if(d1 != -1) {
add_or({sz-1, d1});sz++;
}
d1 = sz-1;
}
//cout << d1 << ":\n";
int a1 = -1;
for(int i = 0; i+k < n+m-1; i++) {
add_and({adiag[i], adiag[i+k]});sz++;
if(a1 != -1) {
add_or({sz-1, a1});sz++;
}
a1 = sz-1;
}
int d2 = -1;
for(int i = 0; i+k < n+m-1; i++) {
vector<int> gg;
for(int j = 0; j < n+m-1; j++) if(j < i || j > i+k)
gg.push_back(diag[j]);
add_or(gg);sz++;
add_not(sz-1);sz++;
if(d2 != -1) {
add_or({sz-1, d2});sz++;
}
d2 = sz-1;
}
int a2 = -1;
for(int i = 0; i+k < n+m-1; i++) {
vector<int> gg;
for(int j = 0; j < n+m-1; j++) if(j < i || j > i+k)
gg.push_back(adiag[j]);
add_or(gg);sz++;
add_not(sz-1);sz++;
if(a2 != -1) {
add_or({sz-1, a2});sz++;
}
a2 = sz-1;
}
//d2&&a2&&(d1|a1)
add_or({a1, d1});sz++;
add_and({d2, a2, sz-1});
}
# | 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... |