## ECOO '16 R1 P4 - Kayenne

View as PDF

Points: 7 (partial)
Time limit: 10.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

The village of Kayenne is divided into a square grid. Residents build their houses where the grid lines intersect. The location of each house is described by a pair of and coordinates, where is the point at the exact centre of town. Each grid line is exactly the same distance from the grid lines on either side of it. Kayenne stretches out from the center for grid lines North, East, South and West. Individuals or families who move to Kayenne are assigned a circular area in which to build their house. This area is centered on a particular grid point and has a radius of . The newcomers are allowed to build their houses on any empty grid point within that circular area (including on the circle boundary).

Some households in Kayenne are Democrat and others are Republican. New households don't get to choose their political affiliations. Instead, their three closest neighbours (determined by the straight line distance between grid locations) vote on their affiliation and the newcomers must abide by the majority decision. Of course, Democrat households always vote that newcomers should be Democrats, and Republican households always vote that they should be Republicans. Occasionally there are ties for the closest neighbour. When this happens, all the neighbours who are the same distance as the closest are also allowed to vote. This can result in an even number of votes, which means that the vote can be tied. In these cases, the newcomers will be Democrats.

The input will contain test cases.

The first line of each test case will consist of two integers and , separated by a space, representing the coordinates of the center of a newcomer's circular building area .

The next lines will each contain two integers and and an uppercase letter separated by single spaces, representing the coordinates and political affiliation of the existing houses in Kayenne .

Your program must output a number representing the percentage chance (rounded to one decimal place) that a newcomer assigned to this circular building area will end up a Democratic household, assuming they choose their building site randomly from the available sites in their area.

Note that the sample data below contains only test case with houses but the test data will contain test cases with houses each.

#### Sample Input

-81 83
15 -198 R
-17 89 R
197 -174 R
-67 89 D
180 -101 D
-78 -173 R
182 121 D
-129 179 R
-100 -53 D
64 -61 D
-123 -152 D
-15 -67 R
20 194 D
125 16 D
133 -28 D
19 -9 R
121 168 D
165 -39 R
-170 -3 D
-27 61 D

#### Sample Output

88.7

#### Question Development Team

Sam Scott (Sheridan College)
Kevin Forest (Sheridan College)
Stella Lau (University of Cambridge)
Greg Reid (St. Francis Xavier Secondary School, Mississauga)
Dino Baron (University of Waterloo)
John Ketelaars (ECOO-CS Communications)
David Stermole (ECOO-CS President)

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org