結果

問題 No.2355 Unhappy Back Dance
ユーザー kumakumakumakuma
提出日時 2023-05-14 01:58:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,323 ms / 6,000 ms
コード長 1,811 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 209,304 KB
実行使用メモリ 44,296 KB
最終ジャッジ日時 2023-08-19 20:55:20
合計ジャッジ時間 20,896 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 63 ms
44,280 KB
testcase_07 AC 107 ms
44,108 KB
testcase_08 AC 128 ms
44,276 KB
testcase_09 AC 128 ms
44,252 KB
testcase_10 AC 226 ms
44,140 KB
testcase_11 AC 222 ms
44,252 KB
testcase_12 AC 141 ms
44,140 KB
testcase_13 AC 142 ms
43,988 KB
testcase_14 AC 250 ms
44,124 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1,306 ms
44,144 KB
testcase_17 AC 1,310 ms
44,252 KB
testcase_18 AC 1,315 ms
44,296 KB
testcase_19 AC 1,314 ms
44,236 KB
testcase_20 AC 1,323 ms
44,256 KB
testcase_21 AC 561 ms
18,532 KB
testcase_22 AC 110 ms
6,504 KB
testcase_23 AC 114 ms
6,544 KB
testcase_24 AC 1,200 ms
40,292 KB
testcase_25 AC 653 ms
24,460 KB
testcase_26 AC 651 ms
24,456 KB
testcase_27 AC 570 ms
18,912 KB
testcase_28 AC 13 ms
4,380 KB
testcase_29 AC 31 ms
4,380 KB
testcase_30 AC 1,119 ms
37,916 KB
testcase_31 AC 823 ms
29,516 KB
testcase_32 AC 82 ms
5,832 KB
testcase_33 AC 463 ms
17,272 KB
testcase_34 AC 6 ms
4,380 KB
testcase_35 AC 15 ms
4,380 KB
testcase_36 AC 584 ms
18,892 KB
testcase_37 AC 303 ms
13,888 KB
testcase_38 AC 364 ms
15,612 KB
testcase_39 AC 303 ms
13,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double PI = 3.141592653589793238462643383279;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> X(N), Y(N);
  for (ll i = 0; i < N; ++i) {
    cin >> X.at(i) >> Y.at(i);

  }
  //y = ax + b
  //gradient = a = dy / dx
  //{dx, dy}
  vector<vector<pll>> gradient(N);
  for (ll i = 0; i < N; ++i) {
    for (ll j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      ll dx = X.at(i) - X.at(j), dy = Y.at(i) - Y.at(j);
      if (dx == 0) {
        if (dy >= 0) {
          gradient.at(i).push_back({INF, 0});
        }
        else {
          gradient.at(i).push_back({-INF, 0});
        }
      }
      else {
        // if (dx < 0) {
        //   dx = -dx;
        //   dy = -dy;
        // }
        ll gcd = abs(__gcd(dx, dy));
        gradient.at(i).push_back({dx / gcd, dy / gcd});
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    sort(rng(gradient.at(i)));
    // cout << "i" << i << "\n";
    // for (ll j = 0; j < gradient.at(i).size(); ++j) {
    //   cout << gradient.at(i).at(j).first << " " << gradient.at(i).at(j).second << "\n";
    // }
    // cout << "\n";
    for (ll j = 0; j < (ll)gradient.at(i).size() - 1; ++j) {
      if (gradient.at(i).at(j) == gradient.at(i).at(j + 1)) {
        ans += 1;
        break;
      }
    }
  }
  cout << ans << "\n";
}
0