who can tell me why i should output 11 for this one:
76.5 53.3 76.5 43.3
-5.1 1.0 4.9 1.0
5.1 0.7 5.1 -9.3
7.3 14.61 7.3 4.61
i think it should be 6
76.5 53.3 76.5 43.3 get 0 points
-5.1 1.0 4.9 1.0 get 5 points
5.1 0.7 5.1 -9.3 get 1 point
7.3 14.61 7.3 4.61 get 0 points
so the answer should be 6!
569 - Horse Shoe Scoring
Moderator: Board moderators
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
The third line shows a Ringer and gives 5 points; note, that not the post itself has to be inside the region of the Horseshoe, only its center ("If the center of the post is within the region bounded by the interior of the horseshoe and the imaginary line connecting the two legs..."). And the last line is a Swinger.
But I have a question to those who already solved the problem: Can you check, if my understanding of Ringer/Toucher/Swinger is correct?
-8.999 0.001 -8.999 -9.999
Ringer
0 0 0 -10
Swinger
-9 0.001 -9 -9.999
Toucher
-9 0 -9 -10
Toucher
0 5.142 0 15.142
Swinger
0 5.143 0 15.143
Nothing
But I have a question to those who already solved the problem: Can you check, if my understanding of Ringer/Toucher/Swinger is correct?
-8.999 0.001 -8.999 -9.999
Ringer
0 0 0 -10
Swinger
-9 0.001 -9 -9.999
Toucher
-9 0 -9 -10
Toucher
0 5.142 0 15.142
Swinger
0 5.143 0 15.143
Nothing
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Is this all about precision? Or is there a catch somewhere. Got tons of WA ![:(](./images/smilies/icon_frown.gif)
Could someone please give me the correct output for this input?
![:(](./images/smilies/icon_frown.gif)
Could someone please give me the correct output for this input?
Code: Select all
0 0 0 -10
0 0 0 -10
0 0 0 -10
0 0 0 -10
0 9 0 -1
0 9 0 -1
0 9 0 -1
0 9 0 -1
0 11 0 1
0 11 0 1
0 11 0 1
0 11 0 1
-9 0 -9 -10
-9 0 -9 -10
-9 0 -9 -10
-9 0 -9 -10
-10 -1 -10 -11
-10 -1 -10 -11
-10 -1 -10 -11
-10 -1 -10 -11
-11 0 -11 -10
-11 0 -11 -10
-11 0 -11 -10
-11 0 -11 -10
0 -5.142 0 -15.142
0 -5.142 0 -15.142
0 -5.142 0 -15.142
0 -5.142 0 -15.142
0 -5.143 0 -15.143
0 -5.143 0 -15.143
0 -5.143 0 -15.143
0 -5.143 0 -15.143
-
- Experienced poster
- Posts: 151
- Joined: Tue Nov 16, 2004 7:23 pm
- Location: Norway
- Contact:
I don't think you have to worry about precision in this problem. As far as my asserts found out (if they were bug-free), there are no cases where the center of the post was exactly on the imaginary line between the ends of the horseshow, or cases where the post touches (but don't intersect) the horseshoe.
My answer to your test cases from my AC program:
My answer to your test cases from my AC program:
Code: Select all
Turn Score
1 4
2 20
3 4
4 20
5 8
6 4
7 4
8 0
569 - wa.
Hi everybody!
I've got WA in problem 569 - Horse Shoe Scoring.
Here is the code:
So, what's wrong with it?
more information:
I've got WA in problem 569 - Horse Shoe Scoring.
Here is the code:
Code: Select all
#include <stdio.h>
#include <math.h>
#define sqr(x) ((x)*(x))
#define POLE_RAD 1.
#define SHOE_RAD 10.
#define SHOE_CHORD (10*sqrt(2.))
#define NUM_TOSSES 4
#define RINGER 5
#define TOUCHER 2
#define SWINGER 1
int main()
{
int turn;
printf("Turn Score\n");
for (turn = 1; feof(stdin); turn++)
{
int score = 0, shoe_count;
for (shoe_count = 0; shoe_count < NUM_TOSSES; shoe_count++)
{
float ax, ay, bx, by;
float px, py;
scanf("%f %f %f %f\n", &ax, &ay, &bx, &by);
bx -= ax;
by -= ay;
px = -(by * ax - bx * ay) / SHOE_RAD;
py = -(bx * ax + by * ay) / SHOE_RAD;
if (px < 0.) px = -px;
if (py >= 0)
{
float dist_a = sqr(px)+sqr(py);
if (dist_a < sqr(SHOE_RAD-POLE_RAD))
score += RINGER;
else if (dist_a < sqr(SHOE_RAD+POLE_RAD))
score += TOUCHER;
else
{
float dist_b = sqr(px) + sqr(py-SHOE_RAD);
if (dist_b <= sqr(SHOE_CHORD+POLE_RAD))
score += SWINGER;
}
}
else
{
float dist_leg = sqr(px-SHOE_RAD) + sqr(py);
if (dist_leg < POLE_RAD)
score += TOUCHER;
else
{
float dist_b = sqr(px) + sqr(py-SHOE_RAD);
if (dist_b <= sqr(SHOE_CHORD+POLE_RAD))
score += SWINGER;
}
}
}
printf("%4d %2d\n", turn, score);
}
return 0;
}
more information:
TIAverdict - wrong answer
language - ANCI C
run time - 0.004
Re: 569 - wa.
"Horse Shoe Problem".
Please, give me the correct output for the input below.
Please, give me the correct output for the input below.
Code: Select all
0 0 0 -10
0 0 0 -10
0 0 0 -10
0 0 0 -10
0 9 0 -1
0 9 0 -1
0 9 0 -1
0 9 0 -1
0 11 0 1
0 11 0 1
0 11 0 1
0 11 0 1
-9 0 -9 -10
-9 0 -9 -10
-9 0 -9 -10
-9 0 -9 -10
-10 -1 -10 -11
-10 -1 -10 -11
-10 -1 -10 -11
-10 -1 -10 -11
-11 0 -11 -10
-11 0 -11 -10
-11 0 -11 -10
-11 0 -11 -10
0 -5.142 0 -15.142
0 -5.142 0 -15.142
0 -5.142 0 -15.142
0 -5.142 0 -15.142
0 -5.143 0 -15.143
0 -5.143 0 -15.143
0 -5.143 0 -15.143
0 -5.143 0 -15.143
-8.999 0.001 -8.999 -9.999
-8.999 0.001 -8.999 -9.999
-8.999 0.001 -8.999 -9.999
-8.999 0.001 -8.999 -9.999
-9 0.001 -9 -9.999
-9 0.001 -9 -9.999
-9 0.001 -9 -9.999
-9 0.001 -9 -9.999
0 5.142 0 15.142
0 5.142 0 15.142
0 5.142 0 15.142
0 5.142 0 15.142
0 5.143 0 15.143
0 5.143 0 15.143
0 5.143 0 15.143
0 5.143 0 15.143