QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408449 | #1950. Surveillance | ohiostatescarlet | WA | 1ms | 3844kb | C++17 | 1.6kb | 2024-05-10 12:27:13 | 2024-05-10 12:27:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define L long long
#define D double
#define P pair<D,D>
D integ(D x, D d) {
return x*(1+1/(d-1)) - x * x * x / (3 * (d - 1));
}
D calcSol(D w, D h) {
double res = -1;
for (int i = 0; i < 2; i++) {
double c = (1 + 1 / (h - 1) - w) * (h - 1);
if (c >= 0) {
c = sqrt(c);
res += integ(1, h) - integ(c, h) + c * w;
} else {
res += integ(1, h);
}
swap(w, h);
}
return res;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
vector<P> nums(n);
for (P&p:nums) cin >> p.first >> p.second;
cout << setprecision(100);
if (n == 4) {
D res = 0;
for (int i = 0; i < n; i++) {
auto [x1, y1] = nums[i];
auto [x2, y2] = nums[(i+1)%n];
res += x1*y2-y1*x2;
}
cout << abs(res/2) << '\n';
} else {
for (int i = 0; i < n; i++) {
auto [x1, y1] = nums[(i-1+n)%n];
auto [x2, y2] = nums[i];
auto [x3, y3] = nums[(i+1)%n];
if ((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1) < 0) {
auto [ox, oy] = nums[(i+3)%n];
D sx = x2 - ox, sy = y2 - oy;
D w = (nums[(i-1+n)%n].first - ox) / sx;
D h = (nums[(i+1)%n].second - oy) / sy;
// cout << ox << " " << oy << " " << sx << " " << sy << " " << w << " " << h << "\n";
cout << abs(calcSol(w, h) * sx * sy) << '\n';
return 0;
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
4 -5 6 -5 -2 10 -2 10 6
output:
120
result:
ok found '120.0000000', expected '120.0000000', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3804kb
input:
6 627 -788 444 -788 444 -986 -102 -986 -102 -993 627 -993
output:
nan
result:
wrong output format Expected double, but "nan" found