QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#97810#4378. Ball3360550356WA 14ms36496kbC++142.5kb2023-04-18 21:02:432023-04-18 21:02:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-18 21:02:46]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:36496kb
  • [2023-04-18 21:02:43]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
const int N = 2e3+10;
const int M = 2e5 + 100;
const int mod = 1e9+7;
const int INF=1e9;
const double PI=acos(-1);
const double eps=1e-10;
struct node{
	int p1,p2,dis;
	
	bool operator<(const node &t)const{
		return dis<t.dis;
	}
	
	
}e[N*N];
int a[N],b[N];
int n,m;
bitset<N> f[N];	


//筛,M为1e5就保证了筛的范围 
int p[N*N];	
int num[N*N];
int idx=0;


void init(){
	memset(p,true,sizeof(p));
	p[1]=false;			//不是素数 
	for(int i=2;i<=M;i++){
		if(p[i])num[++idx]=i;
		for(int j=1;j<=idx&&i*num[j]<=M;j++){
			p[i*num[j]]=false;
			if(i%num[j]==0)break;
		}
	} 
}	 


void solve(){
//	int n,m;
	cin>>n>>m;
	for(int i=1;i<=N;i++){
		f[i].reset();
	}
	
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	
	int cnt=0; 
	for(int i=1;i<=n;i++){
		
		for(int j=i+1;j<=n;j++){
			
			e[++cnt].p1=i;
			e[cnt].p2=j;
			e[cnt].dis=abs(a[i]-a[j])+abs(b[i]-b[j]);
			
		}
	}
	
	sort(e+1,e+1+cnt);
	
	
	int ans=0;
	//枚举当前这条边作为中位数边 
	for(int i=1;i<=cnt;i++){
		
		int p1=e[i].p1;
		int p2=e[i].p2;
		int dis=e[i].dis;
		if(p[dis]){							//如果是素数 
			ans+=(f[p1]^f[p2]).count();		 
		}
		//f[i]表示的是i去到的点j中,满足dist(i,j)小于当前这条边的j有哪些,这里有排序的作用 
		//这个异或操作就保证了p1和p2有一个点到j的距离小于等于dis,一个大于等于dis,绝妙 
		f[p1][p2]=1;
		f[p2][p1]=1; 
	}
	cout<<ans<<endl;
	
} 

signed main() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(0);
	int T=1;
	cin>>T;
	init();
	while(T--) {
		solve();
	}
}

/**
*  ┏┓   ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃       ┃
* ┃   ━   ┃ ++ + + +
*  ████━████+
*  ◥██◤ ◥██◤ +
* ┃   ┻   ┃
* ┃       ┃ + +
* ┗━┓   ┏━┛
*   ┃   ┃ + + + +Code is far away from  
*   ┃   ┃ + bug with the animal protecting
*   ┃    ┗━━━┓ 神兽保佑,代码无bug 
*   ┃        ┣┓
*    ┃        ┏┛
*     ┗┓┓┏━┳┓┏┛ + + + +
*    ┃┫┫ ┃┫┫
*    ┗┻┛ ┗┻┛+ + + +
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 14ms
memory: 36496kb

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:

0
0
0
0
0
0
0
0
0
0

result:

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