QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#41207 | #4378. Ball | youngsystem# | AC ✓ | 1340ms | 28408kb | C++ | 1.4kb | 2022-07-28 18:51:35 | 2022-07-28 18:51:37 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#include<bitset>
#include<algorithm>
#define mod 1000000007
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
bitset<2005>b[2005];
struct sth
{
int d1,d2,jl;
}s[3000005];
bool bi(struct sth x,struct sth y)
{
return x.jl<y.jl;
}
int tmp;
int pri[200005],cnt;
bool vis[200005];
int jdz(int x)
{
if(x<0)return -x;
return x;
}
int x[2005],y[2005];
int main()
{
vis[1]=true;
for(int i=2;i<=200000;i++)
{
if(!vis[i])pri[++cnt]=i;
for(int j=1;j<=cnt&&i*pri[j]<=200000;j++)
{
vis[i*pri[j]]=true;
if(i%pri[j]==0)break;
}
}
int t,n,m;
t=read();
for(int greg=1;greg<=t;greg++)
{
n=read();
m=read();
for(int i=1;i<=n;i++)
{
x[i]=read();
y[i]=read();
}
tmp=0;
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
s[++tmp].d1=i;
s[tmp].d2=j;
s[tmp].jl=jdz(x[i]-x[j])+jdz(y[i]-y[j]);
}
}
sort(s+1,s+tmp+1,bi);
for(int i=1;i<=n;i++)b[i].reset();
long long ans=0;
for(int i=1;i<=tmp;i++)
{
if(!vis[s[i].jl])
{
ans+=(b[s[i].d1]^b[s[i].d2]).count();
}
b[s[i].d1][s[i].d2]=1;
b[s[i].d2][s[i].d1]=1;
}
printf("%lld\n",ans);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1340ms
memory: 28408kb
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:
306097111 113711265 112644014 306052056 111920257 112598067 290930159 115277403 112743440 307026778
result:
ok 10 lines