QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#804545 | #9823. Mouse Trap | Longvu | WA | 18ms | 11680kb | C++23 | 2.1kb | 2024-12-07 23:54:26 | 2024-12-07 23:54:32 |
Judging History
answer
/**
* author: longvu
* created: 12/07/24 21:37:23
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int nax = (int)(201001);
const int mod = 1e9 + 7;
template<class X, class Y>
bool maximize(X& x, const Y y) {
if (y > x) {x = y; return true;}
return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
if (y < x) {x = y; return true;}
return false;
}
struct Point {
int x, y;
};
Point a[nax];
int sufx[nax], sufy[nax], suf[nax];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
a[i] = {x, y};
}
auto cal = [&](Point z, Point t) {
return z.x * t.y - z.y * t.x;
};
int sum = 0, total = 0;
for (int i = 1; i < n; ++i) {
total += cal(a[i], a[i + 1]);
}
total += cal(a[n], a[1]);
total = abs(total);
int sumjx = 0, sumjy = 0, sumex = 0, sumey = 0;
for (int i = 1; i <= n; ++i) {
sumjx += a[i].x * (n - i);
}
for (int i = 1; i <= n; ++i) {
sumjy += a[i].y * (n - i);
}
auto calh = [&](int z) {
return z * (z + 1) / 2;
};
for (int i = 3; i <= n; ++i) {
sumex += a[i].x * (i - 2);
}
for (int i = 3; i <= n; ++i) {
sumey += a[i].y * (i - 2);
}
for (int i = n; i >= 1; --i) {
sufx[i] = a[i].x + sufx[i + 1];
sufy[i] = a[i].y + sufy[i + 1];
}
int sump = 0;
for (int j = 2; j <= n; ++j) {
suf[j] += a[j].x * sufy[j + 1];
suf[j] -= a[j].y * sufx[j + 1];
}
for (int j = n; j >= 1; --j) {
suf[j] += suf[j + 1];
}
for (int i = 1; i < n; ++i) {
sumjx -= a[i].x * (n - i);
sumjy -= a[i].y * (n - i);
sum += a[i].x * sumjy;
sum -= a[i].y * sumjx;
sum += suf[i + 1];
sum += sumex * a[i].y;
sum -= sumey * a[i].x;
sumex -= sufx[i + 2];
sumey -= sufy[i + 2];
}
// cout << sum << " " << total << '\n';
cout << setprecision(21) << fixed << (ld)1.0 * sum / total << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5928kb
input:
4 0 0 1 0 1 1 0 1
output:
2.000000000000000000000
result:
ok found '2.00000', expected '2.00000', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5920kb
input:
5 0 0 1 0 2 1 1 2 0 2
output:
3.666666666666666666739
result:
ok found '3.66667', expected '3.66667', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 5928kb
input:
3 -3141592 -2718281 -3141593 -2718281 -3141592 -2718282
output:
1.000000000000000000000
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 5972kb
input:
4 -10000000 -10000000 10000000 -10000000 10000000 10000000 -10000000 10000000
output:
2.000000000000000000000
result:
ok found '2.00000', expected '2.00000', error '0.00000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 5976kb
input:
6 -10000000 -10000000 0 -10000000 10000000 0 10000000 10000000 0 10000000 -10000000 0
output:
6.000000000000000000000
result:
ok found '6.00000', expected '6.00000', error '0.00000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5908kb
input:
80 -56 -1 -55 -6 -54 -10 -53 -13 -51 -18 -50 -20 -47 -25 -45 -28 -42 -32 -38 -37 -37 -38 -32 -42 -28 -45 -25 -47 -20 -50 -18 -51 -13 -53 -10 -54 -6 -55 -1 -56 0 -56 5 -55 9 -54 12 -53 17 -51 19 -50 24 -47 27 -45 31 -42 36 -38 37 -37 41 -32 44 -28 46 -25 49 -20 50 -18 52 -13 53 -10 54 -6 55 -1 55 0 5...
output:
13022.364675557547910145217
result:
ok found '13022.36468', expected '13022.36468', error '0.00000'
Test #7:
score: 0
Accepted
time: 1ms
memory: 6016kb
input:
4336 -22883 -1 -22882 -43 -22881 -84 -22880 -124 -22879 -163 -22878 -201 -22877 -238 -22876 -274 -22875 -309 -22874 -343 -22873 -376 -22872 -408 -22871 -439 -22870 -469 -22869 -498 -22868 -526 -22867 -553 -22866 -579 -22865 -604 -22864 -628 -22863 -651 -22862 -673 -22861 -694 -22859 -735 -22858 -755...
output:
2071959690.152331388206221163273
result:
ok found '2071959690.15233', expected '2071959690.15233', error '0.00000'
Test #8:
score: -100
Wrong Answer
time: 18ms
memory: 11680kb
input:
199344 -7134251 -1 -7134250 -287 -7134249 -572 -7134248 -856 -7134247 -1139 -7134246 -1421 -7134245 -1702 -7134244 -1982 -7134243 -2261 -7134242 -2539 -7134241 -2816 -7134240 -3092 -7134239 -3367 -7134238 -3641 -7134237 -3914 -7134236 -4186 -7134235 -4457 -7134234 -4727 -7134233 -4996 -7134232 -5264...
output:
10805.617099779855149854768
result:
wrong answer 1st numbers differ - expected: '201338821149252.00000', found: '10805.61710', error = '1.00000'