Finding Celebrities
시간 제한20초메모리 제한1024 MB
A가 B를 아는지 묻는 질문을 Q번 이하로 사용해, 모든 사람이 알지만 아무도 모르는 유명인을 찾는다.
문제
This is an interactive problem.
It is time for the Sogang Computer Science Festival (Korean: 서강대학교 컴퓨터공학과 전산제). people gathered to congratulate the remarkable anniversary of the Department of Computer Science and Engineering.
There is a rumor that a celebrity has come to this festival. You, curious about who the celebrity is, are tasked with finding a celebrity among the people at this festival.
A celebrity is someone known by everyone at this festival who does not know anyone else. You can roam around the festival venue to ask if some person knows some other person . By asking at most questions, determine whether this festival has a celebrity and, if so, identify who it is.
입력
Initially, two space-separated integers are given: , which denotes the number of attendees to this festival, and , which denotes the number of questions you can ask. ( See below for )
출력
You can interact with the judging system by outputting one of the following:
?: Ask if the person knows . ( ) This type of interaction can be made at most times.- The judging system will answer
1if the person knows , or0if they don't.
- The judging system will answer
!: If , identify the celebrity as person . Otherwise, conclude that there is no celebrity in this festival.- Depending on your answer, the judging system will terminate your program and determine the verdict as either Accepted or Wrong Answer.
You should also output a newline character and flush the standard output buffer. Failure to adhere to any of these requirements can result in an unexpected verdict.
힌트
(For Sogang students:) Note that this problem is an improvised version that matches the format of a problem in a general programming contest. While in the exam, the original scoring was:
- Around points for Subtask 1.
- Around points for Subtask 2.