QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#130547 | #1950. Surveillance | karuna# | AC ✓ | 1ms | 3836kb | C++17 | 1.8kb | 2023-07-24 15:13:33 | 2023-07-24 15:13:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
int x[6], y[6];
int d(int u, int v) {
u %= n;
v %= n;
return abs(x[u] - x[v]) + abs(y[u] - y[v]);
}
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
cout.precision(15);
vector<int> p;
for (int i = 0; i < n; i++) {
int a = (i + n - 1) % n;
int b = i;
int c = (i + 1) % n;
if ((x[b] - x[a]) * (y[c] - y[b]) - (y[b] - y[a]) * (x[c] - x[b]) < 0) {
p.push_back(i);
}
}
if (p.size() == 0) {
int H = 0, W = 0;
for (int i = 0; i < n; i++) {
H = max(H, abs(y[(i + 1) % n] - y[i]));
W = max(W, abs(x[(i + 1) % n] - x[i]));
}
cout << fixed << (double)(H * W);
return 0;
}
else {
assert(p.size() == 1);
int s = p[0];
double ans = 0;
double H2 = d(s, s + 1);
double L1 = d(s + 1, s + 2);
double H1 = d(s + 4, s + 5);
double L2 = d(s + 5, s + 6);
if (L1 * H1 > L2 * H2) {
double T = sqrt((L1 * H1 - L2 * H2) * L1 / H1);
ans += 2 * (L1 - T) * (L1 * L1 + L1 * T + T * T) * H1 * H1 / (3 * H2 * L1 * L1);
}
else {
ans += 2 * L1 * H1 * H1 / (3 * H2);
}
swap(H2, L2);
swap(H1, L1);
if (L1 * H1 > L2 * H2) {
double T = sqrt((L1 * H1 - L2 * H2) * L1 / H1);
ans += 2 * (L1 - T) * (L1 * L1 + L1 * T + T * T) * H1 * H1 / (3 * H2 * L1 * L1);
}
else {
ans += 2 * L1 * H1 * H1 / (3 * H2);
}
ans += H1 * L1;
cout << fixed << ans;
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3720kb
input:
4 -5 6 -5 -2 10 -2 10 6
output:
120.000000000000000
result:
ok found '120.0000000', expected '120.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
6 627 -788 444 -788 444 -986 -102 -986 -102 -993 627 -993
output:
1597.422688422688452
result:
ok found '1597.4226884', expected '1597.4226884', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
6 340 110 340 375 -1000 375 -1000 -135 353 -135 353 110
output:
685643.438145167427137
result:
ok found '685643.4381452', expected '685643.4381452', error '0.0000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
6 -182 -316 -182 -286 -672 -286 -672 -353 -580 -353 -580 -316
output:
4677.218525057721308
result:
ok found '4677.2185251', expected '4677.2185251', error '0.0000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
6 -745 -431 -374 -431 -374 217 -587 217 -587 411 -745 411
output:
252676.393735565681709
result:
ok found '252676.3937356', expected '252676.3937356', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
6 -920 341 -920 227 930 227 930 355 -448 355 -448 341
output:
229417.794630740565481
result:
ok found '229417.7946307', expected '229417.7946307', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
6 -939 -133 957 -133 957 334 -69 334 -69 725 -939 725
output:
958691.104770130710676
result:
ok found '958691.1047701', expected '958691.1047701', error '0.0000000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
6 -175 108 -21 108 -21 -421 82 -421 82 171 -175 171
output:
9897.558343357964986
result:
ok found '9897.5583434', expected '9897.5583434', error '0.0000000'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
6 -306 -342 -235 -342 -235 170 -89 170 -89 548 -306 548
output:
48748.232234589042491
result:
ok found '48748.2322346', expected '48748.2322346', error '0.0000000'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
6 -349 185 -218 185 -218 392 -825 392 -825 -218 -349 -218
output:
284794.987926964065991
result:
ok found '284794.9879270', expected '284794.9879270', error '0.0000000'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3832kb
input:
6 -689 -621 551 -621 551 -30 -291 -30 -291 -506 -689 -506
output:
248993.473037456162274
result:
ok found '248993.4730375', expected '248993.4730375', error '0.0000000'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3636kb
input:
4 -836 -551 -719 -551 -719 790 -836 790
output:
156897.000000000000000
result:
ok found '156897.0000000', expected '156897.0000000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
4 276 -742 276 772 -947 772 -947 -742
output:
1851622.000000000000000
result:
ok found '1851622.0000000', expected '1851622.0000000', error '0.0000000'