QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#185736 | #4378. Ball | 321625 | WA | 0ms | 12012kb | C++14 | 1.9kb | 2023-09-22 15:58:20 | 2023-09-22 15:58:20 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#include<vector>
const int N=2007,M=2e5+7;
typedef unsigned long long ull;
ull msk[65],val[N][N][4];int xs[N],ys[N],dst[N][N],p[N][N],rk[N][N];
bool np[M];int prime[M],pc;bool pds[N][N];
std::vector<int> vec[N];
int main()
{
for(int k=0;k<64;++k)msk[k]=1ULL<<k;np[1]=1;
for(int i=2;i<=2e5;++i)
{
if(!np[i])prime[++pc]=i;
for(int j=1;j<=pc&&i*prime[j]<=2e5;++j){np[i*prime[j]]=1;if(!(i%prime[j]))break;}
}
// freopen("11.in","r",stdin);
// freopen("today.in","r",stdin);
// freopen("today.out","w",stdout);
int n,m;ull ans=0;scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)scanf("%d%d",xs+i,ys+i);
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
dst[i][j]=abs(xs[i]-xs[j])+abs(ys[i]-ys[j]);
p[i][j]=j;if(j>i&&!np[dst[i][j]])vec[i].push_back(j);
}
std::swap(p[i][i],p[i][n]);
std::sort(p[i]+1,p[i]+n,[=](int x,int y){
if(dst[i][x]!=dst[i][y])
return dst[i][x]<dst[i][y];
int zx=std::min(i,x),zy=std::min(i,y);
if(zx!=zy)return zx<zy;
return (i^x^zx)<(i^y^zy);
});
for(int j=1;j<n;++j)rk[i][p[i][j]]=j;
}
#define pc __builtin_popcountll
for(int l=1;l<=n;l+=256)
{
int r=std::min(l+255,n);//printf("l=%d(r=%d)\n",l,r);
for(int i=1;i<=n;++i)for(int j=1;j<n;++j)
{
val[i][j][0]=val[i][j-1][0];val[i][j][1]=val[i][j-1][1];
val[i][j][2]=val[i][j-1][2];val[i][j][3]=val[i][j-1][3];
if(l<=p[i][j]&&p[i][j]<=r)val[i][j][(p[i][j]-l)>>6]|=msk[(p[i][j]-l)&63];
// printf("-[%d,%d]\n",i,j);
}
for(int i=1;i<=n;++i)for(int j:vec[i])
{
int x=rk[i][j],y=rk[j][i];
ans+=pc((~val[i][x][0])&val[j][y-1][0])+pc((~val[j][y][0])&val[i][x-1][0]);
ans+=pc((~val[i][x][1])&val[j][y-1][1])+pc((~val[j][y][1])&val[i][x-1][1]);
ans+=pc((~val[i][x][2])&val[j][y-1][2])+pc((~val[j][y][2])&val[i][x-1][2]);
ans+=pc((~val[i][x][3])&val[j][y-1][3])+pc((~val[j][y][3])&val[i][x-1][3]);
}
//printf("l=%d\n",l);
}
printf("%llu",ans);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 12012kb
input:
10 2000 80 9 25 39 66 5 63 59 17 45 19 41 21 21 75 21 61 1 65 29 61 11 23 38 51 1 3 41 59 41 61 61 33 45 65 80 49 38 49 45 79 66 60 61 41 56 33 65 57 26 17 36 1 77 11 13 28 25 41 33 23 66 16 4 73 1 1 57 61 32 11 31 29 42 21 37 69 53 59 1 66 54 70 21 57 65 49 49 18 6 5 11 1 1 67 78 49 43 30 27 1 57 7...
output:
15
result:
wrong answer 1st lines differ - expected: '306097111', found: '15'