QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#56578#4378. BallqinjianbinRE 0ms0kbC++171.1kb2022-10-20 10:55:422022-10-20 10:55:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-20 10:55:44]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-10-20 10:55:42]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = (a) ; i < (b); i++)
#define _for(i, a, b) for(int i = (a) ; i <= (b); i++)
using namespace std;

typedef long long ll;
const int M = 1e5 + 10;
const int N = 2e3 + 10;
bool vis[M];
vector<int> p;
bitset<N> g[N];
int x[N], y[N], n, m;

struct Edge
{
	int u, v, w;
	bool operator < (const Edge& rhs) const
	{
		return w < rhs.w;
	}
};
vector<Edge> e;

void init()
{
	vis[0] = vis[1] = 1;
	_for(i, 2, 1e5)
	{
		if(!vis[i]) p.push_back(i);
		for(int x: p)
		{
			if(i * x > 1e5) break;
			vis[i * x] = 1;
			if(i % x == 0) break;
		}
	}
}
 
int main()
{
	init();

	int T; scanf("%d", &T);
	while(T--)
	{
		e.clear();
		scanf("%d%d", &n, &m);
		_for(i, 1, n) scanf("%d%d", &x[i], &y[i]), g[i].reset();

		_for(i, 1, n)
			_for(j, i + 1, n)
				e.push_back({i, j, abs(x[i] - x[j]) + abs(y[i] - y[j])});
		sort(e.begin(), e.end());

		ll ans = 0;
		for(auto [u, v, w] : e)
		{
			if(!vis[w]) ans += (g[u] ^ g[v]).count();
			g[u][v] = g[v][u] = 1;
		}
		printf("%lld\n", ans);
	}
 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: