QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#602272 | #8775. MountainCraft | LEFt_bank | WA | 1ms | 3840kb | C++20 | 1.8kb | 2024-09-30 22:30:31 | 2024-09-30 22:30:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef double _64;
struct Point {
_64 x, y;
Point(_64 x = 0, _64 y = 0) : x(x), y(y) {}
bool operator==(const Point &a) const {
return x == a.x && y == a.y;
}
Point operator+(const Point &a) const {
return Point(x + a.x, y + a.y);
}
Point operator-(const Point &a) const {
return Point(x - a.x, y - a.y);
}
_64 dot(const Point &a) const {
return x * a.x + y * a.y;
}
_64 cross(const Point &a) const {
return x * a.y - y * a.x;
}
_64 Sdis(const Point &a) const {
return (x - a.x) * (x - a.x) + (y - a.y) * (y - a.y);
}
_64 distance(const Point &a) const {
return sqrt(Sdis(a));
}
};
struct CompareS1 {
bool operator()(const Point &A, const Point &B) const {
return A.y - A.x < B.y - B.x;
}
};
struct CompareS2 {
bool operator()(const Point &A, const Point &B) const {
return A.x + A.y < B.x + B.y;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
set<Point, CompareS1> s1;
set<Point, CompareS2> s2;
int n, w;
cin >> n >> w;
while (n--) {
Point t;
cin >> t.x >> t.y;
if (s1.find(t) != s1.end()) {
s1.erase(t);
s2.erase(t);
} else {
s1.insert(t);
s2.insert(t);
}
if (s1.size()) {
auto [lx, ly] = *s1.rbegin();
auto [rx, ry] = *s2.rbegin();
Point A {lx - min(lx, ly), ly - min(lx, ly)};
Point B {rx + min(w - rx, ry), ry - min(w - rx, ry)};
Point C {(B.x + A.x + B.y - A.y) / 2.0, (B.x - A.x + B.y + A.y) / 2.0};
cout << setprecision(15) << C.distance(A) + C.distance(B) << '\n';
} else {
cout << 0 << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
input:
3 10 3 2 7 3 9 6
output:
5.65685424949238 12.7279220613579 12.7279220613579
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
5 100 31 41 59 26 31 41 59 26 31 41
output:
101.823376490863 120.208152801713 73.5391052434009 0 101.823376490863
result:
ok 5 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
100 10 6 4 2 3 7 6 5 5 3 6 7 5 5 8 10 4 9 8 0 9 9 10 9 3 2 3 10 10 8 4 10 9 0 1 1 7 0 2 3 4 10 3 3 10 7 4 7 5 1 4 0 7 1 9 5 6 8 8 7 4 8 1 3 9 2 1 5 5 2 1 10 9 8 4 0 9 10 7 4 1 9 10 8 6 5 4 1 4 0 9 9 3 4 8 5 10 7 2 8 10 7 10 3 4 2 2 8 5 0 9 5 3 1 4 6 4 0 3 8 1 1 6 3 8 8 4 6 5 10 2 2 2 8 4 6 1 2 4 6 4...
output:
11.3137084989848 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.142135623731 14.14213562...
result:
ok 100 numbers
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3792kb
input:
1000 100 95 8 54 8 64 96 47 34 77 47 99 91 45 70 8 6 64 84 48 42 53 14 73 66 38 27 6 52 19 75 33 39 6 24 37 80 27 45 96 48 55 95 67 1 23 78 40 4 76 7 77 22 4 47 41 31 60 54 96 37 79 52 63 40 7 92 17 7 74 12 93 16 87 5 67 43 60 29 71 58 52 41 53 84 38 2 46 87 13 54 54 14 16 93 57 7 91 98 31 23 70 3 9...
output:
18.3847763108502 76.3675323681471 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.42135623731 141.421356...
result:
wrong answer 2nd numbers differ - expected: '41.0121933', found: '76.3675324', error = '0.8620690'