結果

問題 No.2355 Unhappy Back Dance
ユーザー umezoumezo
提出日時 2023-06-16 22:41:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4,734 ms / 6,000 ms
コード長 1,843 bytes
コンパイル時間 12,339 ms
コンパイル使用メモリ 539,832 KB
実行使用メモリ 355,628 KB
最終ジャッジ日時 2023-09-06 21:08:35
合計ジャッジ時間 71,101 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 24 ms
4,380 KB
testcase_07 AC 28 ms
4,384 KB
testcase_08 AC 802 ms
4,444 KB
testcase_09 AC 938 ms
4,484 KB
testcase_10 AC 1,888 ms
179,672 KB
testcase_11 AC 1,703 ms
179,904 KB
testcase_12 AC 801 ms
4,428 KB
testcase_13 AC 832 ms
4,376 KB
testcase_14 AC 2,852 ms
179,992 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 4,586 ms
355,472 KB
testcase_17 AC 4,555 ms
355,580 KB
testcase_18 AC 4,544 ms
355,512 KB
testcase_19 AC 4,403 ms
355,480 KB
testcase_20 AC 4,734 ms
355,628 KB
testcase_21 AC 1,684 ms
150,456 KB
testcase_22 AC 249 ms
30,708 KB
testcase_23 AC 270 ms
32,644 KB
testcase_24 AC 4,130 ms
321,224 KB
testcase_25 AC 2,092 ms
174,728 KB
testcase_26 AC 2,006 ms
175,380 KB
testcase_27 AC 1,619 ms
153,240 KB
testcase_28 AC 24 ms
6,640 KB
testcase_29 AC 63 ms
11,472 KB
testcase_30 AC 3,835 ms
297,608 KB
testcase_31 AC 2,499 ms
217,708 KB
testcase_32 AC 182 ms
24,496 KB
testcase_33 AC 1,281 ms
125,268 KB
testcase_34 AC 9 ms
4,720 KB
testcase_35 AC 28 ms
7,148 KB
testcase_36 AC 1,643 ms
153,372 KB
testcase_37 AC 827 ms
83,320 KB
testcase_38 AC 1,024 ms
101,704 KB
testcase_39 AC 772 ms
80,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using ll = mp::cpp_int;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  vector<ll> X(n),Y(n);
  rep(i,n) cin>>X[i]>>Y[i];
  vector<pair<ll,ll>> P(n);
  rep(i,n) P[i]={X[i],Y[i]};
  sort(ALL(P));
  
  map<ll,set<int>> m1,m2;
  rep(i,n){
    m1[X[i]].insert(i);
    m2[Y[i]].insert(i);
  }
  set<int> ANS;
  for(auto [a,b]:m1){
    if(b.size()>3){
      for(auto x:b) ANS.insert(x);
    }
    else if(b.size()==3){
      vector<int> T;
      for(auto x:b) T.push_back(x);
      ANS.insert(T[0]);
      ANS.insert(T[2]);
    }
  }
  for(auto [a,b]:m2){
    if(b.size()>3){
      for(auto x:b) ANS.insert(x);
    }
    else if(b.size()==3){
      vector<int> T;
      for(auto x:b) T.push_back(x);
      ANS.insert(T[0]);
      ANS.insert(T[2]);
    }
  }
  map<pair<pair<ll,ll>,pair<ll,ll>>,set<int>> m3;
  for(int i=0;i<n;i++){
    ll xi=P[i].first,yi=P[i].second;
    for(int j=i+1;j<n;j++){
      ll xj=P[j].first,yj=P[j].second;
      if(xi==xj || yi==yj) continue;
      ll dx=xi-xj,dy=yi-yj;
      if(dx<0) dx=-dx,dy=-dy;
      ll g=gcd(dx,dy);
      dx/=g,dy/=g;
      
      ll da=xi*yj-xj*yi,db=xi-xj;
      if(db<0) da=-da,db=-db;
      ll gg=gcd(da,db);
      da/=gg,db/=gg;
      m3[{{dx,dy},{da,db}}].insert(i);
      m3[{{dx,dy},{da,db}}].insert(j);
    }
  }
  for(auto [a,b]:m3){
    if(b.size()>3){
      for(auto x:b) ANS.insert(x);
    }
    else if(b.size()==3){
      vector<int> T;
      for(auto x:b) T.push_back(x);
      ANS.insert(T[0]);
      ANS.insert(T[2]);
    }
  }
  cout<<ANS.size()<<endl;
    
  return 0;
}
0