#include <vector>
#include <string>
#include <map>
using namespace std;
int add_and(std::vector<int> Ns);
int add_or(std::vector<int> Ns);
int add_xor(std::vector<int> Ns);
int add_not(int N);
int h,w,k;
int dia=0,xor1=0;
int dia1=0,xor2=0;
int index_of_diagonal1[401];
int index_of_diagonal2[401];
int f(int i,int j)
{
return (i*w)+j;
}
int check_distance_is_atmost_x(int x)
{
// check subarray of length x+1
vector<int> dp={xor1};
for(int di=0;(di+x)<dia;di++)
{
vector<int> cur;
for(int j=0;j<=x;j++)
cur.push_back(index_of_diagonal1[di+j]);
dp.push_back(add_xor({add_xor(cur),add_or(cur)}));
}
// Ask xor and or
// if xor==0 and or==1 then distance is atmost
// if(dp.size()==0)
// {
// cout<<"size of dp is "<<0<<endl;
// exit(-100);
// }
return add_or(dp);
}
int check_distance_is_atmost_x1(int x)
{
// // check subarray of length x+1
// {
// vector<int> dp;
// for(int di=0;(di)<dia1;di++)
// dp.push_back(di);
// if(add_xor(dp))
// }
vector<int> dp={xor2};
for(int di=0;(di+x)<dia1;di++)
{
vector<int> cur;
for(int j=0;j<=x;j++)
cur.push_back(index_of_diagonal2[di+j]);
dp.push_back(add_xor({add_xor(cur),add_or(cur)}));
}
// Ask xor and or
// if xor==0 and or==1 then distance is atmost
return add_or(dp);
}
void construct_network(int H, int W, int K)
{
h=H;
w=W;
k=K;
for(int j=0;j<1;j++)
{
for(int i=h-1;i>=0;i--)
{
vector<int> element;
int ci=i;
int cj=j;
while(ci<h and cj<w)
{
element.push_back(f(ci,cj));
ci++;
cj++;
}
index_of_diagonal1[dia]=add_or(element);
dia++;
}
}
for(int i=0;i<1;i++)
{
for(int j=1;j<w;j++)
{
int ci=i;
int cj=j;
vector<int> element;
while(ci<h and cj<w)
{
element.push_back(f(ci,cj));
ci++;
cj++;
}
index_of_diagonal1[dia]=add_or(element);
dia++;
}
}
{
vector<int> ship;
for(int i=0;i<dia;i++)
{
ship.push_back(index_of_diagonal1[i]);
}
xor1=add_xor(ship);
}
int fff=check_distance_is_atmost_x(k);
int fss=check_distance_is_atmost_x(k-1);
dia1=0;
for(int i=0;i<1;i++)
{
for(int j=0;j<w;j++)
{
int ci=i;
int cj=j;
vector<int> element;
while(ci<h and cj>=0)
{
element.push_back(f(ci,cj));
ci++;
cj--;
}
index_of_diagonal2[dia1]=add_or(element);
dia1++;
}
}
for(int j=w-1;j<w;j++)
{
for(int i=1;i<h;i++)
{
int ci=i;
int cj=j;
vector<int> element;
while(ci<h and cj>=0)
{
element.push_back(f(ci,cj));
ci++;
cj--;
}
index_of_diagonal2[dia1]=add_or(element);
dia1++;
}
}
{
vector<int> ship;
for(int i=0;i<dia1;i++)
{
ship.push_back(index_of_diagonal2[i]);
}
xor2=add_xor(ship);
}
int fff1=check_distance_is_atmost_x1(k);
int fss1=check_distance_is_atmost_x1(k-1);
add_or({add_and({fff,add_not(fss)}),add_and({fff1,add_not(fss1)})});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
7 ms |
1116 KB |
Output is correct |
3 |
Correct |
7 ms |
1120 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
8 ms |
960 KB |
Output is correct |
7 |
Correct |
6 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
6 ms |
1116 KB |
Output is correct |
11 |
Correct |
7 ms |
1116 KB |
Output is correct |
12 |
Correct |
9 ms |
1112 KB |
Output is correct |
13 |
Correct |
5 ms |
856 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
6 ms |
1116 KB |
Output is correct |
17 |
Correct |
7 ms |
1112 KB |
Output is correct |
18 |
Correct |
7 ms |
1116 KB |
Output is correct |
19 |
Correct |
5 ms |
1112 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
3 ms |
604 KB |
Output is correct |
5 |
Correct |
4 ms |
860 KB |
Output is correct |
6 |
Correct |
3 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
7 ms |
856 KB |
Output is correct |
10 |
Correct |
7 ms |
1116 KB |
Output is correct |
11 |
Correct |
5 ms |
860 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
1116 KB |
Output is correct |
15 |
Correct |
5 ms |
860 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
7 ms |
1116 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
5 ms |
980 KB |
Output is correct |
21 |
Incorrect |
18 ms |
2396 KB |
on inputs (0, 0), (199, 99), expected 0, but computed 1 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1492 KB |
on inputs (126, 120), (176, 169), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |