Task: | Polygon area |
Sender: | minghao |
Submission time: | 2024-11-11 16:38:50 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
Compiler report
input/code.cpp: In function 'void Test()': input/code.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result] 14 | freopen("temp\\in.txt", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=10005; LL x[N], y[N]; LL Cross(int i, int j) { return x[i]*y[j] - y[i]*x[j]; } void Test() { freopen("temp\\in.txt", "r", stdin); } int main() { // Test(); int n; cin >> n; for(int i=1; i<=n; i++) cin >> x[i] >> y[i]; LL ans = 0; for(int i=1; i<=n; i++) { int j = i+1; if(j == n+1) j = 1; ans += Cross(i, j); } cout << abs(ans); 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: ACCEPTED
input |
---|
1000 365625896 -113418831 278762563 38777445 250367343 -96991975 175866909 -129766978 ... |
correct output |
---|
4053466653883387139 |
user output |
---|
4053466653883387139 |
Test 3
Verdict: ACCEPTED
input |
---|
4 -1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000 1000000000 -1000000000 |
correct output |
---|
8000000000000000000 |
user output |
---|
8000000000000000000 |