QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#47484#4378. Ballzzxzzx123WA 1462ms27568kbC++171.2kb2022-09-10 10:38:282022-09-10 10:38:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-10 10:38:30]
  • 评测
  • 测评结果:WA
  • 用时:1462ms
  • 内存:27568kb
  • [2022-09-10 10:38:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2010;
int x[N],y[N];
struct node{
	int i,j,val;
	bool operator<(const node& a)const {
		return val<a.val;
	}
}e[N*N];
int vis[N*N],pri[N*N],cnt;
void init(){
	vis[1]=1;
	for(int i=2;i<N;i++){
		if(!vis[i]){
			pri[++cnt]=i;
		}
		for(int j=1;j<=cnt&&(ll)i*pri[j]<N;j++){
			int v=i*pri[j];
			vis[v]=1;
			if(!(i%pri[j])){
				break;
			}
		}
	}
}
int get_val(int i,int j){
	return abs(x[i]-x[j])+abs(y[i]-y[j]);
}
bitset<N>bi[N];		
int main(){
	int t;
	scanf("%d",&t);
	init();
	while(t--){
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++){
			scanf("%d%d",&x[i],&y[i]);
		}
		int cnt=0;
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				e[++cnt]={i,j,get_val(i,j)};
			}
		}
		sort(e+1,e+cnt+1);
		
		for(int i=1;i<=n;i++){
			bi[i].reset();//全部都比你大 
		}
		int ans=0;
		for(int i=1;i<=cnt;i++){
			int u=e[i].i,v=e[i].j,val=e[i].val;//获得你的编号
			if(!vis[val])
			{
				ans+=(bi[u]^bi[v]).count();
			}
			bi[u][v]=bi[v][u]=1;	
			//接下来考虑删除和添加
		}
		printf("%d\n",ans);
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1462ms
memory: 27568kb

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
1331332644
1331332560
306052056
1331332673
1331332672
290930159
1331332501
1331332463
307026778

result:

wrong answer 2nd lines differ - expected: '113711265', found: '1331332644'