Automotive Navigation
Time limit5sMemory limit256 MB
From a street map, a start point, and per-step distance and compass readings, the program lists every location where the car can be at time t.
- Level
Medium6 of 10
- Topics
- BFS, Graph, Simulation
- Solved
- No attempts yet
Problem
The International Commission for Perfect Cars (ICPC) built a city sized test course for driver assistance systems. Your company, Automotive Control Machines (ACM), runs the test drives on that course.
The course is made of straight streets, and each street runs either east to west or north to south. No street has a dead end, so each end of a street meets another street. There are no grade separated crossings either, so whenever two perpendicular streets pass through the same point they meet there, and a car can turn from one street to the other at that point. A car may not make a U-turn, and a car never leaves the streets. Every street has zero width.
The GPS unit of one car broke down while the car was running on the course, and the driver got lost. The odometer and the electronic compass still work.
You know where the car was at the moment the GPS unit broke, which is time 0. From then on you read the odometer and the compass remotely, once every time unit. A compass reading is one of north, east, south, and west. If you read the compass at the exact moment the car is turning, the reading can be the direction before the turn or the direction after it.
The direction the car was heading at time 0 is unknown. Consider every direction that agrees with the street the car was running on at that moment.
Write a program that reports every location where the car can be right now.
Input
The input is a single test case.
The first line contains four integers , , and : the number of streets (), the x and y coordinates of the car at time 0 when the GPS unit broke, and the current time (). The point lies on some street.
Each of the next lines contains four integers , , , and describes a street running from to , where . Every street runs east to west or north to south, so or holds. No two parallel streets overlap or meet. In this coordinate system the x axis points east and the y axis points north. Every input coordinate is at least 0 and at most 50.
Each of the remaining lines contains an integer (), the measured distance the car ran from time to time , and a letter , the measured direction of the car at time , which is N for north, E for east, W for west, or S for south.
Output
Print every location where the car can be at time that agrees with the measurements. Print one location per line as two integers separated by a single space.
Sort the locations in lexicographic order, so comes before when , or when and .
At least one location on a street agrees with the measurements.