#include<bits/stdc++.h>
#include "vision.h"
using namespace std;
const int X=200;
int h,w;
vector<int> primes;
bool composite[X+10];
int row[X+10]; // id of rows xor
int col[X+10]; // id of columns xor
vector<int> row_p[2];
vector<int> col_p[2];
int row_e[X+10];
int col_e[X+10];
int co(int x,int y)
{
return (x-1)*w+y-1;
}
void construct_network(int H,int W,int K)
{
vector<int> tmp;
h=H;w=W;
int it=h*w;
int n=max(h,w);
for(int i=2;i<=n;i++)
{
if(composite[i])
continue;
primes.push_back(i);
for(int j=2*i;j<=n;j+=i)
composite[j]=true;
}
// rows
for(int i=1;i<=h;i++)
{
row[i]=it++;
tmp.clear();
for(int j=1;j<=w;j++)
tmp.push_back(co(i,j));
add_xor(tmp);
}
// columns
for(int j=1;j<=w;j++)
{
col[j]=it++;
tmp.clear();
for(int i=1;i<=h;i++)
tmp.push_back(co(i,j));
add_xor(tmp);
}
// rows divisors
for(auto p:primes)
{
if(p>h)
break;
vector<int> modt(p);
for(int i=1;i<=p;i++)
{
if(i+p>h)
modt[i-1]=row[i];
else
{
modt[i-1]=it++;
tmp.clear();
for(int j=i;j<=h;j+=p)
tmp.push_back(row[j]);
add_xor(tmp);
}
}
row_p[0].push_back(it++);
add_or(modt);
row_p[1].push_back(it++);
add_not(row_p[0].back());
//cerr<<"row_p "<<p<<" {"<<row_p[1].back()<<","<<row_p[0].back()<<"}\n";
}
// columns divisors
for(auto p:primes)
{
if(p>w)
break;
vector<int> modt(p);
for(int i=1;i<=p;i++)
{
if(i+p>w)
modt[i-1]=col[i];
else
{
modt[i-1]=it++;
tmp.clear();
for(int j=i;j<=w;j+=p)
tmp.push_back(col[j]);
add_xor(tmp);
}
}
col_p[0].push_back(it++);
add_or(modt);
col_p[1].push_back(it++);
add_not(col_p[0].back());
//cerr<<"col_p "<<p<<" {"<<col_p[1].back()<<","<<col_p[0].back()<<"}\n";
}
// rows equal
if(h==1)
{
row_e[0]=it++;
add_not(row[1]);
}
else
{
for(int i=0;i<h;i++)
{
row_e[i]=it++;
tmp.clear();
for(size_t j=0;j<row_p[1].size();j++)
tmp.push_back(row_p[i%primes[j]==0][j]);
add_and(tmp);
//cerr<<"row_e "<<i<<" "<<row_e[i]<<"\n";
}
}
// columns equal
if(w==1)
{
col_e[0]=it++;
add_not(col[1]);
}
else
{
for(int i=0;i<w;i++)
{
col_e[i]=it++;
tmp.clear();
for(size_t j=0;j<col_p[1].size();j++)
tmp.push_back(col_p[i%primes[j]==0][j]);
add_and(tmp);
//cerr<<"col_e "<<i<<" "<<col_e[i]<<"\n";
}
}
// answer
vector<int> ans;
for(int r=0;r<=min(K,h-1);r++)
{
int c=K-r;
if(c>w-1)
continue;
ans.push_back(it++);
tmp={row_e[r],col_e[c]};
add_and(tmp);
}
add_or(ans);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 4), expected 0, but computed 1 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 4), expected 0, but computed 1 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 4), expected 0, but computed 1 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
588 KB |
Output is correct |
2 |
Incorrect |
4 ms |
588 KB |
on inputs (0, 0), (0, 33), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
5 |
Incorrect |
2 ms |
460 KB |
on inputs (0, 0), (100, 28), expected 0, but computed 1 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1820 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
460 KB |
Output is correct |
4 |
Correct |
4 ms |
588 KB |
Output is correct |
5 |
Correct |
5 ms |
588 KB |
Output is correct |
6 |
Correct |
4 ms |
588 KB |
Output is correct |
7 |
Correct |
9 ms |
1128 KB |
Output is correct |
8 |
Correct |
9 ms |
1168 KB |
Output is correct |
9 |
Correct |
22 ms |
1748 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
2 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 0), (0, 4), expected 0, but computed 1 |
22 |
Halted |
0 ms |
0 KB |
- |