QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#45414 | #4378. Ball | miaomiaozi | AC ✓ | 1390ms | 52188kb | C++17 | 1.7kb | 2022-08-23 17:47:58 | 2022-08-23 17:47:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// https://space.bilibili.com/672346917
#ifndef LOCAL
#define LOG(...) 42
#endif
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long LL;
typedef pair <int, int> PII;
constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1);
int multi_cases = 1;
const int N = 2100;
PII a[N];
int do_init = 0;
int prime[300010];
bool st[300010];
int cnt = 0;
void init() {
if (do_init) return;
do_init = 1;
st[1] = st[0] = 1;
for (int i = 2; i <= 300000; i++) if (!st[i]) {
prime[cnt++] = i;
for (int j = i + i; j <= 300000; j += i) if (!st[j]) {
st[j] = 1;
}
}
}
constexpr int M = 2100;
void A_SOUL_AvA () {
int n, m;
cin >> n >> m;
init();
for (int i = 0; i < n; i++) {
cin >> a[i].fi >> a[i].se;
}
vector <array<int, 3>> e;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
e.pb({i, j, abs(a[i].fi - a[j].fi) + abs(a[i].se - a[j].se)});
}
}
sort(all(e), [&](auto &u, auto &v) {
return u[2] < v[2];
});
LL ans = 0;
bitset <M> f[n];
for (auto [i, j, d] : e) {
if (!st[d]) {
ans += (f[i] ^ f[j]).count();
}
f[i][j] = 1, f[j][i] = 1;
}
cout << ans << endl;
}
int main () {
cin.tie(nullptr)->sync_with_stdio(false);
cout << fixed << setprecision(12);
int T = 1;
for (multi_cases && cin >> T; T; T--) {
A_SOUL_AvA ();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1390ms
memory: 52188kb
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