QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#91279 | #4378. Ball | Tobo | WA | 1342ms | 29400kb | C++20 | 1.3kb | 2023-03-28 10:01:30 | 2023-03-28 10:01:32 |
Judging History
answer
#include <bits/stdc++.h>
#define N 2005
using i64 = long long;
using namespace std;
int n, m, x[N], y[N];
int dis(int a, int b)
{
return abs(x[a] - x[b]) + abs(y[b] - y[a]);
}
struct node
{
int x, y, len;
bool operator<(const node &tmp) const
{
return len < tmp.len;
}
} num[N * N];
int pri[200005], vis[200005], tot;
bitset<2005> s[N];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> x[i] >> y[i], s[i].reset();
int cnt = 0;
i64 ans = 0;
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
num[++cnt] = {i, j, dis(i, j)};
sort(num + 1, num + cnt + 1);
for (int i = 1; i <= cnt; i++)
{
auto [u, v, w] = num[i];
if (!vis[w])
ans += (s[u] ^ s[v]).count();
s[u][v] = s[v][u] = 1;
}
cout << ans << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
for (int i = 2; i <= 2e5; i++)
{
if (!vis[i])
pri[++tot] = i;
for (int j = 1; j <= tot && pri[j] * i <= 2e5; j++)
{
vis[i * pri[j]] = 1;
if (i % pri[j] == 0)
break;
}
}
int t = 1;
cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1342ms
memory: 29400kb
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'