結果

問題 No.1144 Triangles
ユーザー 👑 hos.lyrichos.lyric
提出日時 2020-07-31 21:45:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 595 ms / 3,000 ms
コード長 1,676 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 109,048 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 22:42:40
合計ジャッジ時間 9,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 594 ms
4,376 KB
testcase_05 AC 593 ms
4,380 KB
testcase_06 AC 593 ms
4,376 KB
testcase_07 AC 595 ms
4,380 KB
testcase_08 AC 594 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 527 ms
4,380 KB
testcase_15 AC 512 ms
4,376 KB
testcase_16 AC 562 ms
4,380 KB
testcase_17 AC 565 ms
4,376 KB
testcase_18 AC 564 ms
4,380 KB
testcase_19 AC 38 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 534 ms
4,380 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 521 ms
4,376 KB
testcase_25 AC 104 ms
4,380 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 547 ms
4,380 KB
testcase_28 AC 56 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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