結果
| 問題 |
No.947 ABC包囲網
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-19 01:41:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 580 bytes |
| コンパイル時間 | 785 ms |
| コンパイル使用メモリ | 80,292 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 23:16:03 |
| 合計ジャッジ時間 | 4,214 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 60 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int N;
vector<double>X;
int op[10000];
main()
{
cin>>N;
for(int i=0;i<N;i++)
{
int x,y;cin>>x>>y;
X.push_back(atan2(y,x));
}
sort(X.begin(),X.end());
for(int i=0;i<N;i++)
{
double x=X[i];
X.push_back(x+2*M_PI);
}
int id=0;
long ans=0;
for(int i=0;i<N;i++)
{
while(id<2*N&&X[id]<X[i]+M_PI+1e-10)id++;
int jd=id;
for(int j=i+1;j<N;j++)
{
if(X[j]>X[i]+M_PI-1e-10)break;
while(jd<2*N&&X[jd]<X[j]+M_PI-1e-10)jd++;
ans+=jd-id;
}
}
cout<<ans/2<<endl;
}