QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#47059#4378. BallAsukaKyle#WA 1519ms27840kbC++1.7kb2022-09-03 16:34:222022-09-03 16:34:23

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-03 16:34:23]
  • 评测
  • 测评结果:WA
  • 用时:1519ms
  • 内存:27840kb
  • [2022-09-03 16:34:22]
  • 提交

answer

// Author:  HolyK
// Created: Sat Sep  3 16:14:19 2022
#include <bits/stdc++.h>

template <class T, class U>
inline bool smin(T &x, const U &y) {
  return y < x ? x = y, 1 : 0;
}
template <class T, class U>
inline bool smax(T &x, const U &y) {
  return x < y ? x = y, 1 : 0;
}

using LL = long long;
using PII = std::pair<int, int>;
using namespace std;
const int N = 2001, M = 2e5 + 1;

struct node {
  int x, y;
  
  void in() {
    cin >> x >> y;
  }
} a[N];
struct pr {
  int d, i, j;

  friend bool operator < (const pr &a, const pr &b) {
    return a.d < b.d;
  }
} z[N * N];
bitset<N> s[N], o, p;
bool v[M];

void solve() {
  int n, m; cin >> n >> m;
  for(int i = 1; i <= n; i++) {
    a[i].in();
  }
  int tp = 0;
  for(int i = 1; i <= n; i++) {
    for(int j = i + 1; j <= n; j++) {
      int d = abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y);
      z[++tp] = {d, i, j};
    }
  }
  sort(z + 1, z + tp + 1);
  for(int i = 1; i <= n; i++) s[i].reset();
  o.reset();
  for(int i = 1; i <= n; i++) o.set(i);
  int ans = 0;
  for(int i = 1; i <= tp; i++) {
    if(v[z[i].d]) continue;
    s[z[i].i][z[i].j] = s[z[i].j][z[i].i] = 1;
    p = (~s[z[i].i]) & s[z[i].j];
    p[z[i].i] = p[z[i].j] = 0;
    ans += p.count();
    p = (~s[z[i].j]) & s[z[i].i];
    p[z[i].i] = p[z[i].j] = 0;
    ans += p.count();
  }
  cout << ans << '\n';
}

int main() {
  // freopen("t.in", "r", stdin);
  
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int t = 1;
  
  std::cin >> t;
  v[1] = 1;
  for(int i = 2; i < M; i++) {
    if(v[i]) continue;
    for(int j = 2 * i; j < M; j += i) v[j] = 1;
  }
  
  while (t--) {
    solve();
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1519ms
memory: 27840kb

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:

230508862
31798284
31330960
230372346
31249925
31351429
207024332
32085972
31441015
230711195

result:

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