시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
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:

  • If the line ends with a question mark ("?"), your reply must be the string "Quack!".
  • If the line ends with a period ("."), your reply must be the string "*Nod*".
  • If the line is exactly "I quacked the code!", your submission should exit. Reading more input will result in a time limit exceeded and printing more output will result in a wrong answer.

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.

예제 입력 1

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!

예제 출력 1


*Nod*

Quack!

*Nod*

*Nod*

Quack!

*Nod*

Quack!

예제 입력 2

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!

예제 출력 2


*Nod*

Quack!

*Nod*

*Nod*

*Nod*

Quack!

*Nod*

채점 및 기타 정보

  • 예제는 채점하지 않는다.