結果

問題 No.1144 Triangles
ユーザー 👑 hos.lyric
提出日時 2020-07-31 21:45:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 553 ms / 3,000 ms
コード長 1,676 bytes
コンパイル時間 1,317 ms
コンパイル使用メモリ 112,268 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 17:29:22
合計ジャッジ時間 9,143 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }

constexpr Int MO = 1'000'000'007;
constexpr int MAX_N = 2005;

int N;
int X[MAX_N], Y[MAX_N];

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d%d", &X[i], &Y[i]);
  }
  Int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      X[j] -= X[i];
      Y[j] -= Y[i];
    }
    for (int j = i + 1; j < N; ++j) {
      const int a = X[j], b = Y[j];
      Int sum = 0;
      for (int k = j + 1; k < N; ++k) {
        const Int det = a * Y[k] - b * X[k];
        sum += (det < 0) ? -det : det;
      }
      ans += sum;
    }
  }
  if ((ans %= MO) < 0) {
    ans += MO;
  }
  printf("%lld\n", ans);
  return 0;
}
0