Task: | Polygon area |
Sender: | minghao |
Submission time: | 2024-11-11 16:35:03 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
Compiler report
input/code.cpp: In function 'void Test()': input/code.cpp:70:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result] 70 | freopen("temp\\in.txt", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ input/code.cpp: In member function 'void Point::Input()': input/code.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result] 24 | scanf("%lf%lf", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~~~
Code
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=10005; const double EPS = 1e-8, INF=1e20, PI = acos(-1.0); inline int Sign(const double& x) { if(fabs(x) < EPS) return 0; if(x < 0) return -1; else return 1; } struct Point { double x, y; Point(){} Point(double _x, double _y) { x = _x; y = _y; } void Input() { scanf("%lf%lf", &x, &y); } bool operator == (const Point& P)const { return Sign(x - P.x) == 0 && Sign(y - P.y) == 0; } bool operator < (const Point& P)const { return Sign(x - P.x) == 0? Sign(y - P.y)<0 : x<P.x; } double operator ^ (const Point& P)const { return x*P.y - y*P.x; } double operator * (const Point& P)const { return x*P.x + y*P.y; } Point operator + (const Point& P)const { return Point(x+P.x, y+P.y); } Point operator * (const double& _k)const { return Point(x*_k, y*_k); } double len() { return hypot(x, y); } }; struct Polygon { int n; Point p[N]; void Input(int _n) { n = _n; for(int i=0; i<n; i++) p[i].Input(); } double Area() { double ret = 0; for(int i=0; i<n; i++) ret += (p[i] ^ p[(i+1)%n]); return fabs(ret)/2; } }; void Test() { freopen("temp\\in.txt", "r", stdin); } int main() { // Test(); int n; cin >> n; Polygon G; G.Input(n); cout<< (LL)(2*G.Area()); return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
100 -7 -19 91 77 100 100 64 60 ... |
correct output |
---|
43582 |
user output |
---|
43582 |
Test 2
Verdict: WRONG ANSWER
input |
---|
1000 365625896 -113418831 278762563 38777445 250367343 -96991975 175866909 -129766978 ... |
correct output |
---|
4053466653883387139 |
user output |
---|
4053466653883390976 |
Test 3
Verdict: ACCEPTED
input |
---|
4 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 1000000000 -1000000000 |
correct output |
---|
8000000000000000000 |
user output |
---|
8000000000000000000 |