Submission #20202

#TimeUsernameProblemLanguageResultExecution timeMemory
20202taehoon1018초록색 삼각형 (YDX13_green)C++98
0 / 1
2087 ms0 KiB
#include <iostream> #include <iomanip> using namespace std; typedef struct coord { double x, y; }; double area(coord *a, coord *b, coord *c) { double res = 0; res += a->x*b->y; res += b->x*c->y; res += c->x*a->y; res -= b->x*a->y; res -= c->x*b->y; res -= a->x*c->y; if (res < 0) return -res; return res; } int main(void) { coord p[2000]; int N = 0; int a = 0, b = 1, c = 2; double res = 0; cin >> N; if (N < 3) { cout << "0"; return 0; } for (int i = 0; i < N; i++) cin >> p[i].x >> p[i].y; while (a != N - 3) { res += area(p+a, p+b, p+c); if (c == N-1) { if (b == N - 2) { if (a == N - 3) break; else { a++; b = a + 1; c = a + 2; } } else { b++; c = b + 1; } } else c++; } res += area(p + a, p + b, p + c); res *= 3; res /= N; res /= N - 1; res /= N - 2; cout << setprecision(12) << res; }

Compilation message (stderr)

C.cpp:7:1: warning: 'typedef' was ignored in this declaration
 };
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...