QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#634127#9462. Safest Buildingsucup-team133#AC ✓1ms3788kbC++232.0kb2024-10-12 16:44:322024-10-12 16:44:33

Judging History

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

  • [2024-10-12 16:44:33]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3788kb
  • [2024-10-12 16:44:32]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void(0)
#endif

template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& v) {
    for (auto& e : v) {
        is >> e;
    }
    return is;
}

template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    for (std::string_view sep = ""; const auto& e : v) {
        os << std::exchange(sep, " ") << e;
    }
    return os;
}

template <class T, class U = T> bool chmin(T& x, U&& y) {
    return y < x and (x = std::forward<U>(y), true);
}

template <class T, class U = T> bool chmax(T& x, U&& y) {
    return x < y and (x = std::forward<U>(y), true);
}

template <class T> void mkuni(std::vector<T>& v) {
    std::ranges::sort(v);
    auto result = std::ranges::unique(v);
    v.erase(result.begin(), result.end());
}

template <class T> int lwb(const std::vector<T>& v, const T& x) {
    return std::distance(v.begin(), std::ranges::lower_bound(v, x));
}

using namespace std;

using ll = long long;

const int INF = 1e9;

void solve() {
    int n, R, r;
    cin >> n >> R >> r;
    vector<int> ds(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        ds[i] = x * x + y * y;
    }

    if (r == R) {
        cout << n << "\n";
        for (int i = 0; i < n; i++) cout << i + 1 << (i + 1 == n ? "\n" : " ");
        return;
    }
    auto calc = [&](int d2) -> int {
        assert(d2 <= R * R);
        int dr = abs(R - 2 * r);
        if (d2 <= dr * dr) return INF;
        return INF - d2;
    };

    int maxi = calc(ds[0]);
    for (int i = 1; i < n; i++) chmax(maxi, calc(ds[i]));
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        if (calc(ds[i]) == maxi) {
            ans.emplace_back(i + 1);
        }
    }

    cout << ans.size() << "\n";
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int T;
    cin >> T;
    for (; T--;) solve();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3788kb

input:

2
3 10 5
3 4
3 5
3 6
3 10 4
-7 -6
4 5
5 4

output:

1
1
2
2 3

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

100
6 100 50
42 -31
-66 7
13 84
94 13
51 -14
-18 9
12 100 50
-78 56
-56 -64
-22 54
-41 14
-14 55
21 -83
75 21
-51 56
-31 74
-34 79
22 -37
1 -12
14 100 50
15 71
-44 41
-56 78
-48 22
42 -2
-70 28
51 -34
49 -31
-36 67
63 70
34 9
27 -33
36 -93
-52 -19
8 100 14
21 89
67 60
-12 -3
24 -37
-51 14
-30 8
-75 ...

output:

1
6
1
12
1
11
4
3 4 5 6
7
1 4 6 8 9 12 13
1
1
6
2 4 5 7 13 14
7
1 3 4 5 6 7 9
1
11
9
1 2 3 4 5 6 7 8 9
1
29
1
5
1
29
47
1 2 3 4 5 6 7 9 10 11 12 14 17 18 19 21 22 24 25 26 27 28 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46 47 48 50 51 52 53 54 55 56
2
21 29
20
1 5 6 7 10 13 14 18 21 25 26 30 33 3...

result:

ok 1674 tokens

Extra Test:

score: 0
Extra Test Passed