포럼
문제 ICPC00157 ⇄ 인터랙티브

A. Access Denied

설명

Computer passwords have been around for a long time. In fact, 60 years ago CTSS was one of the first computers with a password. The implementation of this was very simple. In CTSS the password was stored in plain text in a file on disk. When logging in, the user would enter a password. The computer would then compare the password to the password on disk. If the comparison failed, it would deny access, if it succeeded, access would be allowed. Researchers at MIT were quick to discover several security flaws in this password system. We will explore one of them, the timing attack.

In a timing attack, we exploit that we can deduce a computation path from the time it takes to do the computation. In CTSS the password check was done using a simple string matching algorithm, similar to this:

verbatim bool CheckPassword(string pwd1, string pwd2) if (pwd1.Length != pwd2.Length) return false;

for (int i = 0; i < pwd1.Length; i++) if (pwd1[i] != pwd2[i]) return false;

return true;

verbatim

For the purpose of this problem, we will use a (very) simplified timing model and the above algorithm. The timing model looks as follows:
- A branching statement (if or for) takes \(1\) ms.
- An assignment, or update of a memory address takes \(1\) ms.
- A comparison between two memory addresses takes \(3\) ms.
- A return statement takes \(1\) ms.

The password consists of between \(1\) and \(20\) English letters, upper or lower case, and digits.

Interaction 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:
- Your program first sends a password string, consisting of between \(1\) and \(20\) English letters, upper or lower case, and digits.
- Depending on if the password is correct, the interactor then responds with either:
- If the password is correct; "ACCESS GRANTED". Your program should then exit cleanly.
- If the password is incorrect; "ACCESS DENIED (\(t\) ms)", where \(t\) is the time it took to verify the password in ms. Your program can then make another guess.

Make sure you flush the buffer after each write. You can guess at most \(2\,500\) times. A testing tool is provided to help you develop your solution. Interaction

제약
입력 형식
출력 형식
인터랙티브 문제
프로그램이 고정된 입력을 읽는 대신 표준 입출력으로 채점기와 메시지를 주고받습니다. 한 줄을 출력할 때마다 표준 출력을 flush하고(예: cout에 endl / print(..., flush=True) / System.out.flush()), 채점기의 응답을 읽으세요. 파일을 읽거나 쓰면 안 됩니다.
예제 1
입력
Hunter2
출력
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NWERC 2021

평가 및 의견

A. Access Denied

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

A. Access Denied

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8