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;
const int maxn=1010;
int n,m,a[maxn],b[maxn];
int d[maxn][maxn],tot;
vector<int> A,B;
int solve(int k) {
for (int i=2;i<=n+m;i++) {
A.clear();
for (int j=1;j<=n;j++) {
if (1<=i-j&&i-j<=m) A.push_back(d[j][i-j]);
}
if (i>2) A.push_back(a[i-1]);
a[i]=add_or(A);
}
for (int i=n+m;i>=2;i--) {
A.clear();
for (int j=1;j<=n;j++) {
if (1<=i-j&&i-j<=m) A.push_back(d[j][i-j]);
}
if (i<n+m) A.push_back(b[i+1]);
b[i]=add_or(A);
}
B.clear();
for (int i=2,j=i+k;j<=n+m;i++,j++) {
A.clear();
A.push_back(a[i]);
A.push_back(b[j]);
B.push_back(add_and(A));
}
return add_or(B);
}
int query(int k) {
int t1=solve(k);
for (int i=1;i<=n;i++)
reverse(d[i]+1,d[i]+m+1);
int t2=solve(k);
for (int i=1;i<=n;i++)
reverse(d[i]+1,d[i]+m+1);
A.clear();
A.push_back(t1);
A.push_back(t2);
return add_or(A);
}
void construct_network(int N, int M, int K) {
n=N; m=M;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
d[i][j]=++tot;
if (K==n+m-2) {
query(K); return;
}
int t1=query(K+1);
int t2=add_not(t1);
int t3=query(K);
A.clear();
A.push_back(t2);
A.push_back(t3);
add_and(A);
}
# | 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... |