QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#189229#6639. Disk Treeucup-team004WA 1ms3552kbC++202.4kb2023-09-27 01:52:252023-09-27 01:52:25

Judging History

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

  • [2023-09-27 01:52:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3552kb
  • [2023-09-27 01:52:25]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    std::vector<int> x(n), y(n), R(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> y[i] >> R[i];
    }
    
    auto cmp = [&](int i, int j) {
        return y[i] < y[j];
    };
    
    std::set<int, decltype(cmp)> s(cmp);
    
    int lst = -1;
    std::vector<std::array<int, 4>> a;
    for (int i = 0; i < n; i++) {
        a.push_back({std::max(x[i] - R[i], 0), 0, y[i], i});
        a.push_back({std::min(x[i] + R[i], int(1E9)), 1, y[i], i});
    }
    
    std::vector<std::array<int, 4>> ans;
    std::sort(a.begin(), a.end());
    
    for (int l = 0, r = 0; l < a.size(); l = r) {
        while (r < a.size() && a[l][0] == a[r][0] && a[l][1] == a[r][1]) {
            r++;
        }
        if (a[l][1] == 1) {
            for (int i = l; i < r; i++) {
                s.erase(a[i][3]);
            }
            lst = a[l][3];
        } else {
            for (int i = l; i < r; i++) {
                auto it = s.lower_bound(a[i][3]);
                if (it != s.begin()) {
                    int j = *std::prev(it);
                    if (i > l && y[j] < a[i - 1][2]) {
                        ans.push_back({a[i][0], a[i][2], a[i - 1][0], a[i - 1][2]});
                    } else {
                        ans.push_back({a[i][0], a[i][2], a[i][0], y[j]});
                    }
                } else if (it != s.end()) {
                    int j = *it;
                    if (i < r - 1 && y[j] > a[i + 1][2]) {
                        ans.push_back({a[i][0], a[i][2], a[i + 1][0], a[i + 1][2]});
                    } else {
                        ans.push_back({a[i][0], a[i][2], a[i][0], y[j]});
                    }
                } else if (i > 0) {
                    ans.push_back({a[i][0], a[i][2], a[i - 1][0], a[i - 1][2]});
                }
            }
            if (s.empty() && lst != -1) {
                ans.push_back({a[l][0], a[l][2], x[lst] + R[lst], y[lst]});
            }
            for (int i = l; i < r; i++) {
                s.insert(a[i][3]);
            }
        }
    }
    
    std::cout << "YES\n";
    for (auto [a, b, c, d] : ans) {
        std::cout << a << " " << b << " " << c << " " << d << "\n";
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 0 3
10 10 6
0 5 1

output:

YES
0 5 0 0
4 10 4 0

result:

ok answer = 1

Test #2:

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

input:

2
1 1 1
3 3 1

output:

YES
2 3 2 1

result:

ok answer = 1

Test #3:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

5
10 10 10
2 0 1
20 20 1
3 20 1
20 0 1

output:

YES
1 0 1 10
2 20 2 10
19 0 19 10
19 20 19 10

result:

ok answer = 1

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3452kb

input:

10
29 29 2
28 55 10
99 81 4
17 82 10
45 88 10
48 68 10
0 8 10
98 95 10
34 0 10
17 24 10

output:

YES
7 24 7 8
7 82 7 24
18 55 18 24
24 0 24 24
27 29 27 24
35 88 35 55
38 68 38 55
88 95 58 68
88 95 58 68
95 81 95 95

result:

wrong answer Two line segments intersect, and it's not only the endpoints that intersect or line segments intersects/touches more than 2 disks