「泉七培训 – 郑予凡」天罚
20%的数据直接模拟
不过要利用弧度制的反三角函数atan2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
//orz yuwan #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<cstdlib> #define ll long long using namespace std; int n,q; bool del[1005]; struct data{int x,y;}a[1005]; inline bool cmpx(data a,data b){return a.x<b.x;} inline int read() { int x=0;char ch=getchar(); while(ch<'0'||ch>'9')ch=getchar(); while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x; } inline double que(int x) { double mn1=10,mn2=10; for(int i=1;i<x;i++) if(!del[i]) { double t=atan2(a[x].x-a[i].x,a[i].y-a[x].y); if(t<mn1)mn1=t; } for(int i=x+1;i<=n;i++) if(!del[i]) { double t=atan2(a[i].x-a[x].x,a[i].y-a[x].y); if(t<mn2)mn2=t; } return mn1+mn2; } int main() { //freopen("lhxsb.in","r",stdin); //freopen("lhxsb.out","w",stdout); n=read();q=read(); for(int i=1;i<=n;i++) a[i].x=read(),a[i].y=read(); sort(a+1,a+n+1,cmpx); for(int i=1;i<=q;i++) { int f=read(),x=read(); if(f==0)del[x]=1; else printf("%lf\n",que(x)); } fclose (stdout); return 0; } |
Subscribe