#include "vision.h"
#include <vector>
#include <iostream>
using namespace std;
int n,m,i,j,k,wh,lim1,lim2;
const int nmax=205;
vector<int> v,fin,l2,c2;
int lin[nmax],col[nmax];
int enc(int A,int B)
{
return (m*A+B);
}
void solve1()
{
for(i=0;i<n;i++)
{
v.clear();
for(j=0;j<m;j++)
v.push_back(enc(i,j));
add_or(v);
lin[i]=++wh;
}
for(j=0;j<m;j++)
{
v.clear();
for(i=0;i<n;i++)
v.push_back(enc(i,j));
add_or(v);
col[j]=++wh;
}
for(i=0;i<n-1;i++)
{
v.clear();
v.push_back(lin[i]);
v.push_back(lin[i+1]);
add_and(v);
++wh;
l2.push_back(wh);
}
for(i=0;i<m-1;i++)
{
v.clear();
v.push_back(col[i]);
v.push_back(col[i+1]);
add_and(v);
++wh;
c2.push_back(wh);
}
++wh;
add_or(l2);
++wh;
add_or(c2);
fin.push_back(wh);
fin.push_back(wh-1);
add_xor(fin);
}
void construct_network(int H, int W, int K) {
n=H,m=W;wh=n*m-1;
if(K==1)
{
solve1();
return;
}
if(H>30||W>30) lim1=1,lim2=1;
else lim1=n,lim2=m;
if(min(H,W)==1) lim1=n,lim2=m;
fin.clear();
for(i=0;i<lim1;i++)
for(j=0;j<lim2;j++)
{
v.clear();
for(k=0;k<=K;k++)
{
if(i+k<H&&j+K-k<W)
{
v.push_back(enc(i+k,j+K-k));
}
if(k>=1&&i-k>=0&&j+K-k<W)
{
v.push_back(enc(i-k,j+K-k));
}
}
if(v.size())
{
if(v.size()>1)
{
add_or(v);
wh++;
v.clear();v.push_back(enc(i,j));v.push_back(wh);
}
else
{
v.push_back(enc(i,j));
}
wh++;
add_and(v);
fin.push_back(wh);
}
}
add_or(fin);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
252 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1244 KB |
on inputs (57, 107), (59, 108), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |