시간 제한 | 메모리 제한 | 제출 | 정답 | 맞은 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 92 | 26 | 22 | 36.066% |
You don't know anything about programming, but nonetheless you and your friend Bob joined the BAPC. Bob just submitted a solution to a problem, but sadly his submission was not accepted. You will help him figure out what mistake he made. In order to do so, he will explain what every part of the program should do according to him. He does not want you to interrupt him while he is explaining, but whenever he is unsure of something, he will ask for confirmation. Bob is actually a very good coder, so whenever he asks for confirmation, he is simply right. You just need to react by nodding and saying "Quack!". As long as you don't interrupt him at the wrong time, and as long as you say "Quack!" at the right times, he will eventually find his mistake and he will shout "I quacked the code!".
This is an interactive problem. Your submission will be run against an interactor, which reads the standard output of your submission and writes to the standard input of your submission. This interaction needs to follow a specific protocol:
The interactor sends one line of text at a time, each line being one sentence of Bob's monologue. You need to reply as follows:
?
"), your reply must be the string "Quack!"..
"), your reply must be the string "*Nod*".Bob's monologue will be no more than $100$ sentences, with at most $10\,000$ characters in total. It is guaranteed that every sentence, except the last one, ends with a question mark ("?
") or a period (".
").
Make sure you flush the buffer after each write.
A testing tool is provided to help you develop your solution.
In the loop, I read a line of input. The method std::getline(std::cin, line); reads until a newline, right? Then I branch according to the last character of the line of input. When the last character is an exclamation mark, I simply terminate the program. When the last character is a question mark, I need to print "Quack!" right? In any other case, I simply print "*Nod*". Wait, to flush the output stream I need to use std::endl instead of '\n' right? I quacked the code!
*Nod* Quack! *Nod* *Nod* Quack! *Nod* Quack!
My program seems to always exit after reading one line. Shouldn't it only halt when a line ends with an exclamation mark? After reading a line, I check the last character using a switch. When the character is a period, I print "*Nod*". When the character is a question mark, I print "Quack!". Wait, both get printed before the program exits? I guess I forgot to add break; here and there... I quacked the code!
*Nod* Quack! *Nod* *Nod* *Nod* Quack! *Nod*
ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2020 Preliminaries D번