Birthday Cake Kattis - birthdaycake (geometry)

Topic links:

https://cn.vjudge.net/problem/Kattis-birthdaycake

Subject to the effect:

Own translation

Specific ideas:

Analyzing are separated by at least one line (line on both sides), and then determines the number of blocks between == candle each candle.

When the number of blocks is determined, which is assumed initially to m lines are parallel, then the current block has m + 1, each intersection of a multi-block is a plurality.

AC Code:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 #define inf 0x3f3f3f3f
 5 #define LL_inf (1ll << 60)
 6 const int maxn = 1e5 + 100;
 7 const int mod = 1e9 + 7;
 8 const double eps = 1e-5;
 9 pair< int, int >sto[maxn];
10 struct node
11 {
12     int a,b,c;
13 } q[maxn];
14 int n,m,r;
15 bool judge(int t1,int t2)
16 {
17     for(int i=1 ; i<=m ; i++ )
18     {
19         int s1=q[i].a*sto[t1].first+q[i].b*sto[t1].second + q[i].c;
20         int s2=q[i].a*sto[t2].first+q[i].b*sto[t2].second + q[i].c;
21         if(s1*s2<0)
22             return true;
23     }
24     return false;
25 }
26 set<pair<double,double >>vis;
27 int main()
28 {
29 
30     scanf("%d %d %d",&n,&m,&r);
31     for(int i = 1; i <= n ; i++ )
32     {
33         scanf("%d %d",&sto[i].first,&sto[i].second);
34     }
35     for(int  i = 1 ; i <= m  ; i++)
36     {
37         scanf("%d %d %d",&q[i].a,&q[i].b,&q[i].c);
38     }
39     int flag=1;
40     for(int  i = 1 ; i <= n ; i++)
41     {
42         for(int  j=1 ; j<=n ; j++)
43         {
44             if(i==j)
45                 continue;
46             if(!judge(i,j))
47             {
48                 printf("no\n");
49                 return 0;
50             }
51         }
52     }
53     for(int i=1; i<=m; i++)
54     {
55         for(int j=1; j<=m; j++)
56         {
57             if(i==j)continue;
58             if(q[i].a*q[j].b==q[i].b*q[j].a)continue;
59               double t1=(q[i].c*q[j].b-q[j].c*q[i].b)*1.0/((q[j].a*q[i].b-q[i].a*q[j].b)*1.0);
60               double t2=(q[i].a*q[j].c-q[i].c*q[j].a)*1.0/(q[j].a*q[i].b-q[i].a*q[j].b);
61               if(t1*t1+t2*t2<r*r)vis.insert(make_pair(t1,t2));
62         }
63     }
64     if(vis.size()+m+1==n){
65     printf("yes\n");
66     }
67     else printf("no\n");
68 return 0;
69 }

 

Guess you like

Origin www.cnblogs.com/letlifestop/p/11069840.html