algorithm - Finding the Number of Positions to Satisfy a Configuration -


you want party complete laser light show. unfortunately, working laser have found located far away house , heavy move, want re-direct laser light house using series of mirrors.

the layout of grid has laser @ position (0,0) pointing north (in positive y direction), , house @ (hx, hy); can think of both laser , house points in 2d plane. there n mirrors (1 <= n <= 100,000) scattered throughout grids aligned @ angles of 45 degrees axes. example, mirror aligned \ take beam of light entering below , reflect left. can think of mirrors being located @ points in 2d plane.

after setting configuration, notice major flaw in plan: laser cannot hit house mirrors in current configuration! result, plan run out onto field, , hold 1 more mirror (placed once again @ 45 degree angle) in order redirect laser onto house. please count number of locations in field can stand accomplish goal.

all coordinates integers between -1,000,000,000 , 1,000,000,000. guaranteed mirrors placed in range well. beam should never come (0,0) after leaving location (and mirrors in initial configuration, guaranteed not happen). no 2 mirrors occupy same point in space, , cannot locate herself @ same position existing mirror.

input format:  * line 1: integers n, hx, , hy.  * lines 2..n + 1: line i+1 describes ith mirror 3 elements:         (x,y) location, , orientation (either '\' or '/').  input:  4 1 2 -2 1 \ 2 1 / 2 2 \ -2 2 /  output format: single integer giving number of locations can stand redirect laser house.  output:  2  output details:  mirror @ (0,1) or (0,2) placed in either direction trick. 

my attempt: attempted brute-force solution. first added mirror random position of field within box 2*hx x 2*hy big , simulated mirrors. if hit home increase count. small input succeeded, when used bigger input program crashed.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -