QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#724895#4378. BallXfJbUhpyzgaW#WA 2550ms29440kbC++142.0kb2024-11-08 15:28:412024-11-08 15:28:42

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 15:28:42]
  • 评测
  • 测评结果:WA
  • 用时:2550ms
  • 内存:29440kb
  • [2024-11-08 15:28:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
struct ed{int x,y,d;}e[2000*2001/2+5];
int pr[N+5],p[N+5],cnt=0;
int x[2005],y[2005];
int d[2005];
int T,n,m,tot;
bitset<2005> gr[2005],le[2005];
int main(){
    // freopen("a.in","r",stdin);
    pr[1]=1;
    for (int i=2;i<=N;++i)
        if (!pr[i]){
            p[++cnt]=i;
            for (int j=1;j<=cnt && 1ll*i*p[j]<=N;++j){
                pr[i*p[j]]=1;
                if (i%p[j]==0) break;
            }
        }
    for (scanf("%d",&T);T;--T){
        scanf("%d%d",&n,&m);tot=0;
        for (int i=1;i<=n;++i) scanf("%d%d",&x[i],&y[i]),gr[i].reset(),le[i].reset();
        for (int i=1;i<=n;++i)
            for (int j=1;j<=n;++j)
                if (j!=i)
                    gr[i].set(j);
        for (int i=1;i<=n;++i)
            for (int j=i+1;j<=n;++j)
                e[++tot]=(ed){i,j,abs(x[i]-x[j])+abs(y[i]-y[j])};
        sort(e+1,e+1+tot,[](ed a,ed b){return a.d<b.d;});
        int ans=0;
        for (int i=1,it1=1,it2=1;i<=tot;++i){
            while (it1<=tot && e[it1].d<e[i].d){
                le[e[it1].x].set(e[it1].y);
                le[e[it1].y].set(e[it1].x);
                ++it1;
            }
            while (it2<=tot && e[it2].d<=e[i].d){
                gr[e[it2].x].flip(e[it2].y);
                gr[e[it2].y].flip(e[it2].x);
                ++it2;
            }
            if (!pr[e[i].d]){
                bitset<2005> t=(le[e[i].x]&gr[e[i].y])|(gr[e[i].x]&le[e[i].y]);
                ans+=t.count();
            }
        }
        for (int i=1,j=1;i<=tot;){
            int tmp=0;
            while (j<=tot && e[j].d==e[i].d){
                tmp+=d[e[j].x]+d[e[j].y];
                ++d[e[j].x],++d[e[j].y];
                ++j;
            }
            if (!pr[e[i].d]) ans+=tmp;
            while (i<=tot){
                --d[e[i].x],--d[e[i].y];
                ++i;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2550ms
memory: 29440kb

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:

676315484
667522892
665632915
676725087
667075454
666140156
672831723
666692767
666373671
676740622

result:

wrong answer 1st lines differ - expected: '306097111', found: '676315484'