結果

問題 No.947 ABC包囲網
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2019-12-03 19:13:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 671 ms / 2,000 ms
コード長 2,164 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 110,268 KB
実行使用メモリ 5,992 KB
最終ジャッジ日時 2023-08-25 14:29:46
合計ジャッジ時間 17,434 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,180 KB
testcase_01 AC 2 ms
5,336 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,272 KB
testcase_04 AC 2 ms
5,264 KB
testcase_05 AC 2 ms
5,108 KB
testcase_06 AC 2 ms
5,336 KB
testcase_07 AC 2 ms
5,292 KB
testcase_08 AC 3 ms
5,136 KB
testcase_09 AC 2 ms
5,016 KB
testcase_10 AC 2 ms
5,192 KB
testcase_11 AC 2 ms
5,260 KB
testcase_12 AC 2 ms
5,264 KB
testcase_13 AC 2 ms
5,264 KB
testcase_14 AC 2 ms
5,484 KB
testcase_15 AC 4 ms
5,284 KB
testcase_16 AC 3 ms
5,360 KB
testcase_17 AC 3 ms
5,216 KB
testcase_18 AC 4 ms
5,380 KB
testcase_19 AC 5 ms
5,164 KB
testcase_20 AC 4 ms
5,420 KB
testcase_21 AC 4 ms
5,224 KB
testcase_22 AC 4 ms
5,212 KB
testcase_23 AC 4 ms
5,224 KB
testcase_24 AC 4 ms
5,400 KB
testcase_25 AC 4 ms
5,392 KB
testcase_26 AC 4 ms
5,224 KB
testcase_27 AC 4 ms
5,604 KB
testcase_28 AC 7 ms
5,564 KB
testcase_29 AC 643 ms
5,740 KB
testcase_30 AC 8 ms
5,768 KB
testcase_31 AC 636 ms
5,712 KB
testcase_32 AC 637 ms
5,688 KB
testcase_33 AC 636 ms
5,636 KB
testcase_34 AC 633 ms
5,688 KB
testcase_35 AC 670 ms
5,652 KB
testcase_36 AC 652 ms
5,704 KB
testcase_37 AC 622 ms
5,672 KB
testcase_38 AC 605 ms
5,796 KB
testcase_39 AC 647 ms
5,704 KB
testcase_40 AC 623 ms
5,612 KB
testcase_41 AC 592 ms
5,992 KB
testcase_42 AC 633 ms
5,728 KB
testcase_43 AC 603 ms
5,648 KB
testcase_44 AC 624 ms
5,948 KB
testcase_45 AC 671 ms
5,660 KB
testcase_46 AC 625 ms
5,688 KB
testcase_47 AC 605 ms
5,656 KB
testcase_48 AC 607 ms
5,612 KB
testcase_49 AC 646 ms
5,744 KB
testcase_50 AC 601 ms
5,648 KB
testcase_51 AC 3 ms
5,400 KB
testcase_52 AC 3 ms
5,324 KB
testcase_53 AC 3 ms
5,324 KB
testcase_54 AC 3 ms
5,252 KB
testcase_55 AC 2 ms
5,304 KB
testcase_56 AC 2 ms
5,172 KB
testcase_57 AC 5 ms
5,292 KB
testcase_58 AC 5 ms
5,232 KB
testcase_59 AC 5 ms
5,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

#define N_MAX 200100

struct bit{
  long long dat[N_MAX + 1];

  void init(){
    for(int i = 0; i < N_MAX; i++){
      dat[i] = 0;
    }
  }

  long long sum(int i){
    long long s = 0;
    while(i > 0){
      s += dat[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, long long x){
    while(i <= N_MAX){
      dat[i] += x;
      i += i & -i;
    }
  }
}bit1;

int main() {
	ll n;
	cin>>n;
	vector<pair<pair<double,ll>,pair<ll,ll> > > vp;
	rep(i,0,n){
		ll a,b;
		cin>>a>>b;
		vp.pb(mp(mp(atan2(a,b),1),mp(a,b)));
		if(a>0)vp.pb(mp(mp(10.,0),mp(-a,-b)));
		else vp.pb(mp(mp(atan2(-a,-b),0),mp(-a,-b)));
	}
	sort(all(vp));
	map<double,ll> ma;
	vector<pair<ll,ll> > v;
	rep(i,0,vp.sz){
		if(vp[i].fi.se==1){
			v.pb(mp(vp[i].se.fi,vp[i].se.se));
		}
		ma[vp[i].fi.fi] = i+10;
	}
	bit1.init();
	rep(i,0,v.sz){
		ll x = v[i].fi;
		ll y = v[i].se;
		bit1.add(ma[atan2(x,y)],1);
	}
	ll ans = 0;
	rep(i,0,v.sz){
		ll x1 = v[i].fi;
		ll y1 = v[i].se;
		if(x1>=0)continue;
		double a11,a12;
		a11 = atan2(x1,y1);
		if(x1>0)a12 = 10.;
		else a12 = atan2(-x1,-y1);
		rep(j,i+1,v.sz){
			ll x2 = v[j].fi;
			ll y2 = v[j].se;
			double a21,a22;
			a21 = atan2(x2,y2);
			if(x2>0)a22 = 10.;
			else a22 = atan2(-x2,-y2);
			if(a11==a21)continue;
			if(a21>=a12)continue;
			ll high = ma[a22]-1;
			ll low = ma[a12];
			ans += bit1.sum(high)-bit1.sum(low);
		}
	}
	cout << ans << endl;
	return 0;
}
0