fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define sd(x) scanf("%d", &(x))
  6. #define pii pair<int, int>
  7. #define F first
  8. #define S second
  9. #define all(c) ((c).begin()), ((c).end())
  10. #define sz(x) ((int)(x).size())
  11. #define ld long double
  12.  
  13. template<class T,class U>
  14. ostream& operator<<(ostream& os,const pair<T,U>& p){
  15. os<<"("<<p.first<<", "<<p.second<<")";
  16. return os;
  17. }
  18.  
  19. template<class T>
  20. ostream& operator <<(ostream& os,const vector<T>& v){
  21. os<<"{";
  22. for(int i = 0;i < (int)v.size(); i++){
  23. if(i)os<<", ";
  24. os<<v[i];
  25. }
  26. os<<"}";
  27. return os;
  28. }
  29.  
  30. #ifdef LOCAL
  31. #define cerr cout
  32. #else
  33. #endif
  34.  
  35. #define TRACE
  36.  
  37. #ifdef TRACE
  38. #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  39. template <typename Arg1>
  40. void __f(const char* name, Arg1&& arg1){
  41. cerr << name << " : " << arg1 << std::endl;
  42. }
  43. template <typename Arg1, typename... Args>
  44. void __f(const char* names, Arg1&& arg1, Args&&... args){
  45. const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
  46. }
  47. #else
  48. #define trace(...)
  49. #endif
  50.  
  51. struct PT{
  52. ll a, b;
  53. PT(){}
  54. PT(ll _a, ll _b) : a(_a), b(_b){};
  55. PT operator - (const PT & p) const{
  56. return PT(a - p.a, b - p.b);
  57. }
  58. PT operator + (const PT & p) const{
  59. return PT(a + p.a, b + p.b);
  60. }
  61.  
  62. ll operator * (const PT & p) const{
  63. return (a * p.b - b * p.a);
  64. }
  65. };
  66.  
  67. const int N = 100005;
  68. PT P[N];
  69. int main(){
  70. int n; sd(n);
  71. for(int i = 0; i < n; i++){
  72. scanf("%lld", &P[i].a),scanf("%lld", &P[i].b);
  73. assert(max(abs(P[i].a), abs(P[i].b)) <= 1e7);
  74. }
  75. ll areaP = 0, area = 0;
  76.  
  77. for(int i = 0; i < n; i++){
  78. PT p = P[i] - P[(i + n - 1) % n], q = P[(i + 1) % n] - P[i];
  79. ll z = p * q;
  80. assert(z > 0);
  81. area += abs(p * q);
  82. areaP += p * P[i];
  83. }
  84. areaP = abs(areaP);
  85. printf("%.10lf\n", (4 * areaP - area) / 8.);
  86. }
Runtime error #stdin #stdout #stderr 0s 4516KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog: prog.cpp:80: int main(): Assertion `z > 0' failed.