Problem 3 Raincast
Здравейте, някой знае ли защо не ми излиза последния тест и ми дава 90/100?
Код: https://pastebin.com/nQsTntEe
The Raindear Forecast Agency has hired you again, astonished by your previous works. This time you are hired to write a software which receives Telegram Raincasts, and validates them. The messages are quite scrambled so you only have to find the valid ones.
You will begin receiving input lines which may contain any ASCII character. Your task is to find the Raincasts.
The Valid Raincast consists of 3 lines:
- Type: {type}
- Source: {source}
- Forecast: {forecast}
The type should either be “Normal”, “Warning” or “Danger”.
The source should consist of alphanumeric characters.
The forecast should not contain any of the following characters: ‘!’, ‘.’, ‘,’, ‘?’.
- When you find a type, you must search for a source.
- When you find a source you must search for a forecast.
- When you find a forecast, you have completed a single Valid Raincast. You must start searching for a type again, for the next Raincast.
There might be invalid lines between the valid ones. You should keep the order of searching.
NOTE: The valid input lines must be exactly in the format specified above. Any difference makes them invalid.
When you receive the command “Davai Emo”, the input ends. You must print all valid raincasts you’ve found, each in a specific format, each on a new line.
Input
- The input will come in several input lines which may contain any ASCII character.
- The input ends when you receive the command “Davai Emo”.
Output
- As output you must print all of the valid raincasts you’ve found, each on a new line.
- The format is: ({type}) {forecast} ~ {source}
Constraints
- The input lines may contain any ASCII character.
- There will be no more than 100 input lines.
- Allowed working time / memory: 100ms / 16MB.
Examples
Input |
Output |
Type: Normal Source: JohnKutchur9 Forecast: A full rain program no sun Type: Danger Forecast: Invalid Input Line Source: IvoAndreev Type: Invalid Input Line Forecast: Shte vali qko Davai Emo |
(Normal) A full rain program no sun ~ JohnKutchur9 (Danger) Shte vali qko ~ IvoAndreev |
Forecast: Bau Source: Myau Type: Strong Source: Good Forecast: Valid Type: Warning Type: Danger Source: Emo Forecast: Nqma da se kefim mn na praznici Davai Emo |
(Warning) Nqma da se kefim mn na praznici ~ Emo |