| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 15009 | That Time I Got Reincarnated as a Roomba II |
|
| 15010 | Show Me the Count |
|
Description
Hurray! Your first shift went well and you are still alive. Your owner was satisfied with the clean room, but all that dirt clogged your brush. Until he buys a replacement, he just wants you to patrol the living room and report back.
Your bumper still works the same way. A command that would take you out of the room is refused outright, and you wait for the next one. You no longer clean anything; you only move. The rest of the rules remain the same:
- If a command would take you outside of the room, you do not move at all, you skip the command and you go on to read the next command.
- If you receive the command
STOP, it ends your shift immediately. Any commands that come afterwards are skipped. - If the commands run out, your shift has ended.
- By the end of your shift, you need to output your location in the living room. You also need to report to your owner how many commands you skipped.
Note: you can try using while-loop when solving this problem.
Input
The first line is five integers. The first one is the number of command you will received com . The next two are R rows and C columns. Rows are numbered 0 to R-1 from top to bottom, columns 0 to C-1 from left to right; basically 0-indexed. The last two are your initial position in the living room sr -th row and sc -th column.
The next com lines are either:
<dir> <steps>where<dir>is one ofN,S,E,W, which mean north, south, east, and west correspondingly.<steps>is a positive integer of how many steps you will take within the grid.STOPwhich means you need to discard all the next commands.
Constraints
- 1 ≤
com≤ 100 - 1 ≤
R,C≤ 100 - 0 ≤
sr<R, 0 ≤sc<C <dir>is one ofN,S,E,W- 1 ≤
<steps>≤ 100
Output
First line of output is your fr final row and fc column in the grid. The next line is the number of how many commands you have skipped (including the commands that come after the command STOP if applicable).
Sample Input Download
Sample Output Download
Tags
Discuss
Description
You are studying to become the next best rapper in South Korea, so you started watching the rapper TV show and study the rappers. The way you study is you count how many times each word appears in the transcript. However, since you are lazy but smart, you decided to code an algorithm that can count them for you from the transcript passed to you.
Here are the methods of counting:
- The transcript is given as one single line.
- Counting is case-insensitive (i.e.
Yo,YO, andyoare the same word. Output words in lowercase). - The characters
.,!?are treated as separators, the same as whitespace. Soflow,rhymecounts as two words. - Any other character (including
'and-) is part of the word.don'tstaysdon't. - Words are separated by whitespace and/or the punctuation above.
- If the line contains no words, print
EMPTY.
You need to output the word and the frequency of it, sorted by the frequency descending.
Input
One line containing the transcript. Length ≤ 1000 characters.
Output
One line per distinct word, in the format <word> <frequency> , sorted by frequency in descending order. If two words have the same count, sort them in lexicographic (ASCII) order, ascending. Note that ' and - come before letters in ASCII, so don't comes before dont.