QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#94726 | #4378. Ball | zyoobn | WA | 2460ms | 51416kb | C++20 | 1.2kb | 2023-04-07 17:00:56 | 2023-04-07 17:01:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
constexpr int N = 2e5;
vector<int> primes;
vector<bool> isPrime(N + 1, true);
void solve() {
int n, m;
cin >> n >> m;
vector<array<int, 2>> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i][0] >> a[i][1];
}
vector<array<int, 3>> g;
for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
g.push_back({abs(a[i][0] - a[j][0]) + abs(a[i][1] - a[j][1]), i, j});
}
}
sort(g.begin(), g.end());
i64 ans = 0;
vector<bitset<2000>> f(n);
for (auto &[w, u, v] : g) {
if (isPrime[w]) {
ans += (f[u] ^ f[v]).count();
}
f[u][v] = 1, f[v][u] = 1;
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
for (int i = 2; i <= N; i++) {
if (isPrime[i]) {
primes.push_back(i);
}
for (auto &p : primes) {
if (i * p > N) {
break;
}
isPrime[i * p] = false;
if (i % p == 0) {
break;
}
}
}
int t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2460ms
memory: 51416kb
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:
306098391 113711265 112644014 306053263 111920257 112598067 290930671 115277403 112743440 307028116
result:
wrong answer 1st lines differ - expected: '306097111', found: '306098391'