QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#178006#4378. Balljrjyy#WA 2482ms51328kbC++201.5kb2023-09-13 17:12:332023-09-13 17:12:33

Judging History

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

  • [2023-09-13 17:12:33]
  • 评测
  • 测评结果:WA
  • 用时:2482ms
  • 内存:51328kb
  • [2023-09-13 17:12:33]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
constexpr int N = 2000, M = 2e5;

std::vector<int> pri;
std::vector<bool> vis;

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<std::pair<int, int>> a(n);
    for (auto &[x, y] : a) {
        std::cin >> x >> y;
        --x, --y;
    }

    std::vector<std::tuple<int, int, int>> edges;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int x = std::abs(a[i].first - a[j].first) + std::abs(a[i].second - a[j].second);
            edges.emplace_back(x, i, j);
        }
    }

    std::sort(edges.begin(), edges.end());
    std::vector<std::bitset<N>> adj(n);
    i64 ans = 0;
    for (auto [w, u, v] : edges) {
        if (!vis[w]) {
            ans += (adj[u] & ~adj[v]).count();
            ans += (~adj[u] & adj[v]).count();
        }
        adj[u].set(v);
        adj[v].set(u);
    }

    std::cout << ans << "\n";
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    vis.resize(M + 1);
    for (int i = 2; i <= M; ++i) {
        if (!vis[i]) {
            pri.push_back(i);
        }
        for (auto p : pri) {
            if (i * p > M) {
                break;
            }
            vis[i * p] = true;
            if (i % p == 0) {
                break;
            }
        }
    }

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2482ms
memory: 51328kb

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'