QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#50431 | #4838. Rotate Sum 2 | YaoBIG# | AC ✓ | 51ms | 6388kb | C++17 | 1.8kb | 2022-09-26 01:26:27 | 2022-09-26 01:26:29 |
Judging History
answer
#include "bits/stdc++.h"
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define revrep(i, a, n) for (int i = n; i >= a; --i)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
using namespace std;
string to_string(const string &s) { return '"' + s + '"'; }
template<class A> string to_string(A v) {
bool first = 1;
string res = "{";
for (const auto &x: v) {
if (!first) res += ", ";
first = 0;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template<class H, class... T> void debug_out(H h, T... t) {
cerr << " " << to_string(h);
debug_out(t...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
using vi = vector<int>;
using ll = long long;
using pii = pair<int, int>;
template<class T> struct Point {
using P = Point;
using type = T;
static constexpr T eps = 1e-9;
T x, y;
P operator -(P a) const { return P{x - a.x, y - a.y}; }
T dot(P b) { return x * b.x + y * b.y; }
T cross(P b) { return x * b.y - y * b.x; }
};
int main() {
ios::sync_with_stdio(0); cin.tie(0);
using T = long double;
using P = Point<T>;
int n; cin >> n;
vector<P> as(n);
for (auto &[x, y]: as) cin >> x >> y;
T sum2 = 0;
T sum_x = 0, sum_y = 0;
for (auto [x, y]: as) {
sum2 += x * x + y * y;
sum_x += x;
sum_y += y;
}
T ans = 0;
rep(i, 0, n - 1) {
auto a = as[i];
auto b = as[(i - 1 + n) % n];
auto c = as[(i + 1) % n];
auto th = atan2((a - b).cross(c - a), (a - b).dot(c - a));
auto [x, y] = as[i];
T S = sum2 - 2 * sum_x * x - 2 * sum_y * y + (x * x + y * y) * n;
ans += S * th / 2;
}
ans /= n;
rep(i, 0, n - 1) {
P a = as[i] - as[0];
P b = as[(i + 1) % n] - as[0];
ans += a.cross(b) / 2;
}
printf("%.10f\n", (double) ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3812kb
input:
3 1 -1 1 1 -1 2
output:
18.7632345032
result:
ok found '18.76323', expected '18.76323', error '0.00000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3856kb
input:
4 -1000000000 1000000000 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000
output:
16566370614359173120.0000000000
result:
ok found '16566370614359173120.00000', expected '16566370614359173120.00000', error '0.00000'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3796kb
input:
10 -54592357 -80406461 -54592497 -80409914 -54583785 -80448527 -54573150 -80452302 -54571418 -80445561 -54573057 -80436942 -54574710 -80428961 -54576431 -80421748 -54581146 -80413624 -54586843 -80406612
output:
3241469216.9621667862
result:
ok found '3241469216.96217', expected '3241469216.96217', error '0.00000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
100 19218707 41938436 19227173 41936741 19236439 41934895 19244714 41933329 19263050 41933508 19269952 41935468 19276958 41938057 19283547 41941029 19290649 41944891 19298015 41949938 19301176 41952107 19308530 41957785 19315067 41963572 19323587 41972122 19331125 41980143 19339499 41989094 19341411...
output:
168840266155.0430908203
result:
ok found '168840266155.04309', expected '168840266155.04294', error '0.00000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1000 -40710097 -68387840 -40713262 -68382547 -40715876 -68378183 -40720034 -68371279 -40724775 -68363579 -40730740 -68353973 -40736549 -68344830 -40739819 -68339713 -40742687 -68335270 -40746895 -68328767 -40752947 -68319823 -40754886 -68316968 -40761079 -68308110 -40767747 -68298732 -40770472 -6829...
output:
14911692181599.2109375000
result:
ok found '14911692181599.21094', expected '14911692181599.02734', error '0.00000'
Test #6:
score: 0
Accepted
time: 7ms
memory: 3800kb
input:
10000 84849929 -57126112 84841472 -57123352 84836897 -57121859 84827816 -57118905 84819535 -57116213 84810908 -57113420 84809250 -57112891 84802608 -57110788 84797710 -57109239 84789766 -57106738 84783187 -57104673 84773775 -57101720 84766522 -57099445 84757149 -57096507 84751370 -57094702 84745393 ...
output:
1412486655950655.2500000000
result:
ok found '1412486655950655.25000', expected '1412486655950472.75000', error '0.00000'
Test #7:
score: 0
Accepted
time: 12ms
memory: 4104kb
input:
20000 36695920 63855096 36699821 63853995 36702135 63853342 36706473 63852120 36712051 63850550 36717151 63849119 36721923 63847781 36730794 63845294 36739373 63842890 36745062 63841296 36751484 63839501 36760104 63837093 36769910 63834359 36779620 63831652 36788710 63829118 36797797 63826588 368057...
output:
5727102515432270.0000000000
result:
ok found '5727102515432270.00000', expected '5727102515430790.00000', error '0.00000'
Test #8:
score: 0
Accepted
time: 18ms
memory: 4836kb
input:
50000 63220612 55859143 63226689 55860975 63228549 55861536 63237384 55864204 63246036 55866818 63253128 55868961 63262941 55871927 63272384 55874783 63278109 55876515 63285718 55878817 63289955 55880101 63297340 55882339 63305978 55884958 63313100 55887118 63321418 55889645 63330759 55892485 633335...
output:
35262276012490316.0000000000
result:
ok found '35262276012490316.00000', expected '35262276012467580.00000', error '0.00000'
Test #9:
score: 0
Accepted
time: 36ms
memory: 6284kb
input:
100000 6150629 209064536 6145207 209063168 6135217 209060644 6125551 209058201 6115985 209055782 6108484 209053885 6099150 209051524 6093683 209050141 6084620 209047848 6081814 209047138 6072408 209044758 6064213 209042684 6055932 209040588 6047114 209038356 6037530 209035930 6028054 209033531 60199...
output:
141307819505803120.0000000000
result:
ok found '141307819505803120.00000', expected '141307819505619632.00000', error '0.00000'
Test #10:
score: 0
Accepted
time: 51ms
memory: 6256kb
input:
99989 -135597084 24675451 -135596066 24669344 -135594745 24661432 -135593849 24656066 -135593366 24653174 -135591982 24644890 -135590618 24636739 -135590005 24633076 -135588796 24625860 -135587482 24618020 -135586605 24612788 -135585381 24605487 -135583879 24596531 -135583397 24593658 -135582102 245...
output:
141081441398671568.0000000000
result:
ok found '141081441398671568.00000', expected '141081441398487584.00000', error '0.00000'
Test #11:
score: 0
Accepted
time: 8ms
memory: 3848kb
input:
12432 -53030605 62756639 -53020643 62747841 -53011057 62739377 -53003690 62732873 -52999478 62729161 -52992709 62723198 -52986581 62717802 -52979396 62711476 -52974388 62707069 -52973366 62706172 -52970127 62703330 -52965879 62699603 -52955918 62690870 -52948653 62684509 -52940428 62677331 -52931644...
output:
2216015628957820.7500000000
result:
ok found '2216015628957820.75000', expected '2216015628957463.75000', error '0.00000'
Test #12:
score: 0
Accepted
time: 46ms
memory: 6388kb
input:
95846 96281192 -1877350 96286947 -1871034 96291470 -1866068 96300515 -1856135 96306553 -1849500 96315540 -1839624 96320958 -1833670 96328658 -1825206 96336295 -1816811 96341317 -1811290 96348753 -1803115 96355968 -1795181 96360393 -1790315 96366306 -1783812 96372117 -1777421 96375231 -1773996 963804...
output:
129057360308079760.0000000000
result:
ok found '129057360308079760.00000', expected '129057360307918736.00000', error '0.00000'
Test #13:
score: 0
Accepted
time: 28ms
memory: 5532kb
input:
77877 134743677 56655124 134749156 56665110 134753149 56672389 134758418 56681995 134761944 56688425 134766712 56697123 134770923 56704806 134775444 56713057 134779077 56719688 134782792 56726469 134788085 56736131 134789440 56738605 134793460 56745946 134798926 56755928 134803171 56763683 134807060...
output:
85342605030245408.0000000000
result:
ok found '85342605030245408.00000', expected '85342605030159280.00000', error '0.00000'
Test #14:
score: 0
Accepted
time: 25ms
memory: 4496kb
input:
44722 -1000000000 -1000000000 -999999999 -999999999 -999999998 -999999996 -999999997 -999999991 -999999996 -999999984 -999999995 -999999975 -999999994 -999999964 -999999993 -999999951 -999999992 -999999936 -999999991 -999999919 -999999990 -999999900 -999999989 -999999879 -999999988 -999999856 -99999...
output:
4607558515693524480.0000000000
result:
ok found '4607558515693524480.00000', expected '4607558515691559936.00000', error '0.00000'
Test #15:
score: 0
Accepted
time: 13ms
memory: 4084kb
input:
30000 -999999999 -999999999 -999999997 -999999991 -999999995 -999999975 -999999993 -999999951 -999999990 -999999900 -999999989 -999999879 -999999987 -999999831 -999999984 -999999744 -999999983 -999999711 -999999982 -999999676 -999999980 -999999600 -999999979 -999999559 -999999977 -999999471 -9999999...
output:
4605025704222344704.0000000000
result:
ok found '4605025704222344704.00000', expected '4605025704221045760.00000', error '0.00000'
Test #16:
score: 0
Accepted
time: 7ms
memory: 4040kb
input:
23333 -1000000000 -1000000000 -999999996 -999999984 -999999994 -999999964 -999999993 -999999951 -999999992 -999999936 -999999991 -999999919 -999999986 -999999804 -999999985 -999999775 -999999983 -999999711 -999999979 -999999559 -999999977 -999999471 -999999976 -999999424 -999999975 -999999375 -99999...
output:
4608776827539032064.0000000000
result:
ok found '4608776827539032064.00000', expected '4608776827538008064.00000', error '0.00000'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3824kb
input:
10 -999998304 -997123584 -999995033 -975328911 -999991449 -926880399 -999989625 -892359375 -999986588 -820118256 -999985688 -795166656 -999983492 -727485936 -999982787 -703712631 -999975967 -422414911 -999964606 252735236
output:
1962446719359847168.0000000000
result:
ok found '1962446719359847168.00000', expected '1962446719359846912.00000', error '0.00000'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3820kb
input:
4 0 -1000000000 1 -1 2 999999999 1 0
output:
4712388975672300544.0000000000
result:
ok found '4712388975672300544.00000', expected '4712388975672300544.00000', error '0.00000'