#![allow(unused_imports, unused_macros, dead_code)] use std::{cmp::*, collections::*}; fn main() { let mut sc = Scanner::new(); let n: usize = sc.cin(); let mut ps = vec![]; for _ in 0..n { let x: f64 = sc.cin(); let y: f64 = sc.cin(); ps.push(Point(x, y)); } let p = Polygon(ps); put!((p.area() * 2.0) as u64); } // @geometry2d/polygon // @geometry2d/point /// Geometry2D - Definition of Point #[derive(Debug, Clone, Copy)] pub struct Point(pub f64, pub f64); impl Point { pub fn new(x: f64, y: f64) -> Self { Self(x, y) } pub fn zero() -> Point { Point(0.0, 0.0) } pub fn norm(&self) -> f64 { (*self * *self).sqrt() } pub fn det(&self, other: &Point) -> f64 { self.0 * other.1 - self.1 * other.0 } pub fn arg(&self) -> f64 { let x = self.0 / self.norm(); let y = self.1 / self.norm(); y.atan2(x) } pub fn distance(&self, other: &Point) -> f64 { (*self - *other).norm() } } impl PartialEq for Point { fn eq(&self, other: &Point) -> bool { let eps = 1e-6; (self.0 - other.0).abs() < eps && (self.1 - other.1).abs() < eps } fn ne(&self, other: &Point) -> bool { !(self == other) } } impl Eq for Point {} impl std::ops::Add for Point { type Output = Point; fn add(self, other: Point) -> Point { Point(self.0 + other.0, self.1 + other.1) } } impl std::ops::Neg for Point { type Output = Point; fn neg(self) -> Point { Point(-self.0, -self.1) } } impl std::ops::Sub for Point { type Output = Point; fn sub(self, other: Point) -> Point { self + (-other) } } // scalar multiplication impl std::ops::Mul for f64 { type Output = Point; fn mul(self, other: Point) -> Point { Point(self * other.0, self * other.1) } } impl std::ops::Mul for Point { type Output = Point; fn mul(self, other: f64) -> Point { Point(other * self.0, other * self.1) } } // inner-product impl std::ops::Mul for Point { type Output = f64; fn mul(self, other: Point) -> f64 { self.0 * other.0 + self.1 * other.1 } } impl std::ops::Div for Point { type Output = Point; fn div(self, other: f64) -> Point { Point(self.0 / other, self.1 / other) } } /// Geometry2D - Definition of Polygon #[derive(Debug, Clone)] pub struct Polygon(Vec); impl Polygon { pub fn len(&self) -> usize { self.0.len() } } impl std::ops::Index for Polygon { type Output = Point; fn index(&self, idx: usize) -> &Self::Output { &self.0[idx] } } impl Polygon { pub fn area(&self) -> f64 { (1..self.len() - 1) .map(|i| { let u = self[i] - self[0]; let v = self[i + 1] - self[0]; u.det(&v).abs() }) .sum::() / 2.0 } } #[macro_export] macro_rules! poly { ($($x:expr),+) => {{ let v = vec![$($x),+]; Polygon(v) }}; ($($x:expr),+ ,) => (poly!($($x),+)) } // {{{ use std::io::{self, Write}; use std::str::FromStr; struct Scanner { stdin: io::Stdin, buffer: VecDeque, } impl Scanner { fn new() -> Self { Self { stdin: io::stdin(), buffer: VecDeque::new(), } } fn cin(&mut self) -> T { while self.buffer.is_empty() { let mut line = String::new(); let _ = self.stdin.read_line(&mut line); for w in line.split_whitespace() { self.buffer.push_back(String::from(w)); } } self.buffer.pop_front().unwrap().parse::().ok().unwrap() } fn chars(&mut self) -> Vec { self.cin::().chars().collect() } fn vec(&mut self, n: usize) -> Vec { (0..n).map(|_| self.cin()).collect() } } fn flush() { std::io::stdout().flush().unwrap(); } #[macro_export] macro_rules! min { (.. $x:expr) => {{ let mut it = $x.iter(); it.next().map(|z| it.fold(z, |x, y| min!(x, y))) }}; ($x:expr) => ($x); ($x:expr, $($ys:expr),*) => {{ let t = min!($($ys),*); if $x < t { $x } else { t } }} } #[macro_export] macro_rules! max { (.. $x:expr) => {{ let mut it = $x.iter(); it.next().map(|z| it.fold(z, |x, y| max!(x, y))) }}; ($x:expr) => ($x); ($x:expr, $($ys:expr),*) => {{ let t = max!($($ys),*); if $x > t { $x } else { t } }} } #[macro_export] macro_rules! trace { ($x:expr) => { #[cfg(debug_assertions)] eprintln!(">>> {} = {:?}", stringify!($x), $x) }; ($($xs:expr),*) => { trace!(($($xs),*)) } } #[macro_export] macro_rules! put { (.. $x:expr) => {{ let mut it = $x.iter(); if let Some(x) = it.next() { print!("{}", x); } for x in it { print!(" {}", x); } println!(""); }}; ($x:expr) => { println!("{}", $x) }; ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) } } #[macro_export] macro_rules! ndarray { ($x:expr;) => { $x }; ($x:expr; $size:expr $( , $rest:expr )*) => { vec![ndarray!($x; $($rest),*); $size] }; } // }}}