QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#766111 | #692. Delete the Points | pan_g | WA | 0ms | 3816kb | C++20 | 2.1kb | 2024-11-20 16:14:00 | 2024-11-20 16:14:08 |
Judging History
answer
#include <bits/stdc++.h>
#define endl "\n"
typedef long long i64;
typedef double lb;
signed main(){
std::cin.tie(nullptr) -> sync_with_stdio(false);
int n;
std::cin >> n;
std::cout << "Yes" << endl;
std::map<int, std::vector<int> > mp;
for(int i = 0, x, y;i < n;i++){
std::cin >> x >> y;
mp[x].emplace_back(y);
}
std::cout << std::fixed << std::setprecision(3);
lb tx = -1, ty = -1;
auto delete_with_t = [&](lb x, lb y) -> void {
lb len = std::max(std::fabs(x - tx), std::fabs(y - ty));
lb r = std::max(ty, y);
std::cout << x - len - 0.5 << ' ' << r - len - 0.5 << ' ' << x + 0.5 << ' ' << r + 0.5 << endl;
tx = ty = -1;
};
auto delete_pair = [&](lb x, lb sy, lb by) -> void {
lb y = x - (by - sy);
std::cout << y - 0.5 << ' ' << sy - 0.5 << ' ' << x + 0.5 << ' ' << by + 0.5 << endl;
};
for(auto &[x, f] : mp){
sort(f.begin(), f.end());
int i = 0, m = f.size();
if(tx == -1){
for(;i + 1 < m;i += 2) delete_pair(x, f[i], f[i + 1]);
if(m & 1) tx = x, ty = f.back();
}
else{
for(;i + 1 < m && f[i + 1] < ty;i += 2) delete_pair(x, f[i], f[i + 1]);
if(i < m && f[i] <= ty){
lb delx = (lb)x - tx;
lb dely = ty - f[i];
if(i == m - 1 || f[i + 1] > ty){
delete_with_t(x, f[i]);
i ++;
}
else{
if(delx >= dely){
delete_pair(x, f[i], f[i + 1]);
i += 2;
}
else{
delete_with_t(x, f[i]);
i ++;
}
}
}
if(tx >= 0 && i < m){
delete_with_t(x, f[i]);
i ++;
}
for(;i + 1 < m;i += 2) delete_pair(x, f[i], f[i + 1]);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
input:
4 1 1 2 2 5 5 6 6
output:
Yes 0.500 0.500 2.500 2.500 4.500 4.500 6.500 6.500
result:
ok OK
Test #2:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
4 0 0 1 2 2 1 4 4
output:
Yes -1.500 -0.500 1.500 2.500 0.500 0.500 4.500 4.500
result:
ok OK
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
4 1 2 3 2 2 1 2 3
output:
Yes 0.500 0.500 2.500 2.500
result:
wrong answer Unexpected EOF