Page 1 of 1

569 - Horse Shoe Scoring

Posted: Fri Sep 13, 2002 9:14 am
by cedroger
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!

Posted: Tue Mar 09, 2004 6:04 pm
by Adrian Kuegel
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

Posted: Tue Mar 09, 2004 6:23 pm
by Adrian Kuegel
Nevermind, I got Accepted.

Posted: Fri May 06, 2005 11:53 am
by little joey
Is this all about precision? Or is there a catch somewhere. Got tons of WA :(

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

Posted: Sun Jun 19, 2005 4:07 pm
by stubbscroll
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:

Code: Select all

Turn Score
   1     4
   2    20
   3     4
   4    20
   5     8
   6     4
   7     4
   8     0

569 - wa.

Posted: Thu Nov 12, 2009 10:13 am
by own
Hi everybody!
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; 
}
So, what's wrong with it?
more information:
verdict - wrong answer
language - ANCI C
run time - 0.004
TIA

Re: 569 - wa.

Posted: Sat Jan 02, 2010 7:29 pm
by own
"Horse Shoe Problem".
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   

Re: 569 - wa.

Posted: Tue Jan 12, 2010 3:49 pm
by own
Nevermind, I got AC.