Programming contest problem

Hey guys, I'm trying to solve what seems like a simple problem:
http://acmicpc-live-archive.uva.es/nuevoportal/data/problem.php?p=4168

and just so you know, you can validate a program by submitting it to:
http://cii-judge.baylor.edu/

Now I have no idea what I'm doing wrong. My program passes the test cases just fine but I'm at my wits end figuring out why my program is not being accepted. My general suspicion is it has something to do with double precision. Here is my code, see if any of you can figure it out:
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
55
56
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

bool debug = false;

double dist(double x1, double y1, double x2, double y2);

int main()
{
	int currSet = 0;
	while(true)
	{
		currSet++;
		double currX, currY;
		int shoeDist;	//the distance you can travel in one turn
		int currFlyX=0, currFlyY=0;
		bool flyWasCaught = false;
		cin >> shoeDist >> currX >> currY;
		if (!shoeDist)
			break;
		int caughtAtX, caughtAtY;
		cin >> currFlyX >> currFlyY;
		while (!(currFlyX == -1 && currFlyY == -1))
		{
			//analyze this flash
			double distance = dist(currX, currY, currFlyX, currFlyY);
			if (distance - shoeDist <= 1)
			{
				flyWasCaught = true;
				caughtAtX = currFlyX;
				caughtAtY = currFlyY;
			}
			//find new position
			if (!flyWasCaught)
			{
				double p = shoeDist / distance;
				currX += ((double)currFlyX - currX) * p;
				currY += ((double)currFlyY - currY) * p;
			}
			cin >> currFlyX >> currFlyY;
		}
		if (flyWasCaught)
			cout << "Firefly " << currSet << " caught at (" << caughtAtX << "," << caughtAtY << ")\n";
		else
			cout << "Firefly " << currSet << " not caught\n";
	}
}

double dist(double x1, double y1, double x2, double y2)
{
	return sqrt( pow(x1-x2, 2) + pow(y1-y2, 2) );
}


Sorry don't have your answer but is there a section on the website saying what this contest is about and how it works? I was just wondering because it looks interesting to me and I want to find out information about it.
Last edited on
Topic archived. No new replies allowed.