結果
| 問題 |
No.1447 Greedy MtSaka
|
| コンテスト | |
| ユーザー |
mugen_1337
|
| 提出日時 | 2021-03-31 14:02:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 3,096 bytes |
| コンパイル時間 | 2,959 ms |
| コンパイル使用メモリ | 196,184 KB |
| 最終ジャッジ日時 | 2025-01-20 01:13:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
struct IOSetup{
IOSetup(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(12);
}
} iosetup;
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
for(T &x:v)is>>x;
return is;
}
#line 2 "geometry/base.cpp"
namespace geometry {
using Real = double;
const Real EPS = 1e-8;
const Real PI = acos(static_cast< Real >(-1));
enum {
OUT, ON, IN
};
inline int sign(const Real &r) {
return r <= -EPS ? -1 : r >= EPS ? 1 : 0;
}
inline bool equals(const Real &a, const Real &b) {
return sign(a - b) == 0;
}
}
#line 3 "geometry/point.cpp"
namespace geometry {
using Point = complex< Real >;
istream &operator>>(istream &is, Point &p) {
Real a, b;
is >> a >> b;
p = Point(a, b);
return is;
}
ostream &operator<<(ostream &os, const Point &p) {
return os << real(p) << " " << imag(p);
}
Point operator*(const Point &p, const Real &d) {
return Point(real(p) * d, imag(p) * d);
}
// rotate point p counterclockwise by theta rad
Point rotate(Real theta, const Point &p) {
return Point(cos(theta) * real(p) - sin(theta) * imag(p), sin(theta) * real(p) + cos(theta) * imag(p));
}
Real cross(const Point &a, const Point &b) {
return real(a) * imag(b) - imag(a) * real(b);
}
Real dot(const Point &a, const Point &b) {
return real(a) * real(b) + imag(a) * imag(b);
}
bool compare_x(const Point &a, const Point &b) {
return equals(real(a), real(b)) ? imag(a) < imag(b) : real(a) < real(b);
}
bool compare_y(const Point &a, const Point &b) {
return equals(imag(a), imag(b)) ? real(a) < real(b) : imag(a) < imag(b);
}
using Points = vector< Point >;
}
#line 2 "geometry/polygon.cpp"
#line 4 "geometry/polygon.cpp"
namespace geometry {
using Polygon = vector< Point >;
using Polygons = vector< Polygon >;
}
#line 3 "geometry/area.cpp"
namespace geometry {
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A
Real area(const Polygon &p) {
int n = (int) p.size();
Real A = 0;
for(int i = 0; i < n; ++i) {
A += cross(p[i], p[(i + 1) % n]);
}
return A * 0.5;
}
}
using namespace geometry;
signed main(){
int n;cin>>n;
Polygon p(n);
for(auto &x:p) cin>>x;
Real ans=area(p);
ans*=2;
ans+=0.0001;
cout<<int(ans)<<endl;
return 0;
}
mugen_1337