ural 1246. Tethered Dog

http://acm.timus.ru/problem.aspx?space=1&num=1246

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #define maxn 200010
 5 using namespace std;
 6 
 7 struct node
 8 {
 9     double x,y;
10 }p[maxn];
11 
12 double cross(node a,node b,node c)
13 {
14     return (c.x-a.x)*(b.y-a.y)-(c.y-a.y)*(b.x-a.x);
15 }
16 
17 int main()
18 {
19     int n;
20     scanf("%d",&n);
21     for(int i=1; i<=n; i++)
22     {
23         scanf("%lf%lf",&p[i].x,&p[i].y);
24     }
25     p[n+1]=p[1]; p[0]=p[n];
26     int c=0;
27     for(int i=1; i<=n; i++)
28     {
29         if(p[i].x>p[c].x)
30         {
31             c=i;
32         }
33     }
34     if(c==0) c=n;
35     if(cross(p[c-1],p[c],p[c+1])>=0) printf("cw\n");
36     else printf("ccw\n");
37     return 0;
38 }
View Code

 

posted @ 2014-03-25 19:25  null1019  阅读(196)  评论(0编辑  收藏  举报