QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#58610 | #692. Delete the Points | james1BadCreeper | WA | 3ms | 3812kb | C++ | 2.2kb | 2022-10-27 09:26:53 | 2022-10-27 09:26:55 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXX = 1e9;
int n;
struct stone {
int x, y;
bool operator < (const stone &a) const {
if (x != a.x) return x < a.x;
return y < a.y;
}
} a[3005];
bool v[3005];
void solve(void)
{
memset(v, 0, sizeof(v));
puts("Yes");
for (int i = n; i >= 1; ) {
if (v[i]) { --i; continue; }
int j = i - 1;
while (v[j]) --j;
if (a[i].x == a[j].x) {
printf("%d %d ", a[i].x, a[i].y);
printf("%d %d\n", a[i].x + a[i].y - a[j].y, a[j].y);
v[i] = v[j] = true;
}
else if (a[i].y >= a[j].y) {
printf("%d %d ", a[j].x, a[j].y);
int w = max(a[i].x - a[j].x, a[i].y - a[j].y);
printf("%d %d\n", a[j].x + w, a[j].y + w);
v[i] = v[j] = true;
}
else {
int k = j - 1;
if (k == 0 || a[k].x < a[j].x || a[k].y < a[i].y) {
printf("%d %d ", a[j].x, a[i].y);
int w = max(a[i].x - a[j].x, a[j].y - a[i].y);
printf("%d %d\n", a[j].x + w, a[i].y + w);
v[i] = v[j] = true;
}
else if (a[k].y > a[i].y) {
printf("%d %d ", a[k].x, a[k].y);
printf("%d %d\n", a[k].x + (a[j].y - a[k].y), a[j].y);
v[k] = v[j] = true;
}
else if (a[j].y - a[k].y <= a[i].x - a[k].x) {
printf("%.2lf %d ", a[j].x - 0.5, a[j].y);
printf("%.2lf %d\n", a[j].x - 0.5 + a[j].y - a[k].y, a[k].y);
v[j] = v[k] = true;
}
else {
printf("%d %d ", a[k].x, a[k].y);
printf("%d %d\n", a[i].x, a[k].y + (a[i].x - a[k].x));
v[i] = v[k] = true;
}
}
}
}
int main(void) {
int T;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d%d", &a[i].x, &a[i].y);
sort(a + 1, a + n + 1);
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3812kb
input:
4 1 1 2 2 5 5 6 6
output:
Yes 0 0 2 2 Yes 5 5 6 6 Yes 5 5 6 6 Yes 5 5 6 6
result:
wrong answer Expected double but found NAN.