NC236061. Laser Trap
描述
输入描述
There are multiple test cases. The first line of the input contains an integerindicating the number of test cases. For each test case:
The first line contains an integer(
) indicating the number of laser generators.
For the followinglines, the
-th line contains two integers
and
(
) indicating the location of the
-th laser generator.
It is guaranteed that no two generators coincide, and no laser beam or generator will touch.
It is also guaranteed that the sum ofof all test cases will not exceed
.
输出描述
For each test case output one line containing one integer indicating the minimum number of generators that need to be removed.
示例1
输入:
3 2 1 0 2 0 3 1 0 0 1 -1 -1 5 2 -1 1 2 -1 2 -2 -1 0 -2
输出:
0 1 2
C++ 解法, 执行用时: 1335ms, 内存消耗: 31712K, 提交时间: 2022-04-09 16:49:48
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<=b;++i) const long double pi=acosl(-1); int n; long double a[(int)2e6+9]; int main(){ int cse;cin>>cse; while(cse--){ cin>>n; rep(i,1,n){ int u,v;cin>>u>>v; a[i] = atan2l(1.0*v,1.0*u); } sort(a+1,a+1+n); rep(i,1,n) a[i+n]=a[i]+2*pi; int j=1,ans=1e9; rep(i,1,n){ while(j<=(n<<1)&&a[j] - a[i] < pi) j++; ans=min(ans,j-i-1); } cout<<ans<<endl; } return 0; }