QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#189228 | #6639. Disk Tree | ucup-team004 | WA | 1ms | 3504kb | C++20 | 2.3kb | 2023-09-27 01:51:14 | 2023-09-27 01:51:14 |
Judging History
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]});
}
}
}
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: 0
Wrong Answer
time: 1ms
memory: 3504kb
input:
3 1 0 3 10 10 6 0 5 1
output:
YES 4 10 4 0
result:
wrong output format Unexpected end of file - int32 expected