QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408453 | #1950. Surveillance | ohiostatescarlet | AC ✓ | 1ms | 3944kb | C++17 | 1.6kb | 2024-05-10 12:35:10 | 2024-05-10 12:35:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define L long long
#define D long 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 = max(abs((x1 - ox) / sx), abs((x3 - ox) / sx));
D h = max(abs((y1 - oy) / sy), abs((y3 - 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: 3776kb
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: 0
Accepted
time: 1ms
memory: 3780kb
input:
6 627 -788 444 -788 444 -986 -102 -986 -102 -993 627 -993
output:
1597.4226884226885483375468766098492778837680816650390625
result:
ok found '1597.4226884', expected '1597.4226884', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
6 340 110 340 375 -1000 375 -1000 -135 353 -135 353 110
output:
685643.4381451675066045936546288430690765380859375
result:
ok found '685643.4381452', expected '685643.4381452', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
6 -182 -316 -182 -286 -672 -286 -672 -353 -580 -353 -580 -316
output:
4677.2185250577213277978216865449212491512298583984375
result:
ok found '4677.2185251', expected '4677.2185251', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
6 -745 -431 -374 -431 -374 217 -587 217 -587 411 -745 411
output:
252676.393735565685830124493804760277271270751953125
result:
ok found '252676.3937356', expected '252676.3937356', error '0.0000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3864kb
input:
6 -920 341 -920 227 930 227 930 355 -448 355 -448 341
output:
229417.794630740458359241529251448810100555419921875
result:
ok found '229417.7946307', expected '229417.7946307', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
6 -939 -133 957 -133 957 334 -69 334 -69 725 -939 725
output:
958691.10477013080134156552958302199840545654296875
result:
ok found '958691.1047701', expected '958691.1047701', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
6 -175 108 -21 108 -21 -421 82 -421 82 171 -175 171
output:
9897.5583433579651657652220819727517664432525634765625
result:
ok found '9897.5583434', expected '9897.5583434', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
6 -306 -342 -235 -342 -235 170 -89 170 -89 548 -306 548
output:
48748.232234589042104033751456881873309612274169921875
result:
ok found '48748.2322346', expected '48748.2322346', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
6 -349 185 -218 185 -218 392 -825 392 -825 -218 -349 -218
output:
284794.987926964101603743984014727175235748291015625
result:
ok found '284794.9879270', expected '284794.9879270', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
6 -689 -621 551 -621 551 -30 -291 -30 -291 -506 -689 -506
output:
248993.47303745617256254263338632881641387939453125
result:
ok found '248993.4730375', expected '248993.4730375', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
4 -836 -551 -719 -551 -719 790 -836 790
output:
156897
result:
ok found '156897.0000000', expected '156897.0000000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
4 276 -742 276 772 -947 772 -947 -742
output:
1851622
result:
ok found '1851622.0000000', expected '1851622.0000000', error '0.0000000'