ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1246. Tethered Dog

please give me a test, I have WA 15 =)
Posted by Samsonov Ivan (Rybinsk SAAT) 24 Aug 2007 07:45
#include <iostream>

using namespace std;

int main()
{
   int N,z=0,z1,z2;
   int x1,y1,x2,y2,x3,y3;
   cin >> N >> x1 >> y1 >> x2 >> y2;
   N-=2;
   int xx1=x1,yy1=y1;
   x1 =x2 - x1;
   y1 =y2 - y1;
   int xx=x1,yy=y1;
   while (N--)
   {
       cin >> x3 >> y3;
       z1 =x3 - x2;
       z2 =y3 - y2;
       z+= x1*z2-z1*y1;
       x1 = z1;
       y1 = z2;
       x2 = x3;
       y2 = y3;
   }
   z1 = xx1-x3;
   z2 = yy1-y3;
    z+= z1*yy-z2*xx;
   if (z<0)
       cout << "cw";
   else
       cout << "ccw";
   return 0;
}

Edited by author 24.08.2007 15:33
Re: please give me a test, I have WA 4
Posted by AlexF [USTU Frogs] 24 Aug 2007 08:50
I think you've forgotten about the 1st and nth points) And also you should write something like z += ... to count the total direction)
Good Luck!))

Edited by author 24.08.2007 08:57
Re: please give me a test, I have WA 15 =)
Posted by FORGOTTEN (Samara STU) 22 Nov 2007 21:53
I had the same problem. But when I replaced "int" with "double", I've got AC. Just try to calculate next expression: 50000*50000 - 50000*(-50000) = ???????????