cswork / OA打开练习工作台

AmazonOA #336

Return Records

估计简单可在线判题

考点(AI 标注)模拟/实现哈希计数

Implement the register, login and logout endpoints of a mock website. Process n requests in order and output the return value of each request.

register username password: if the username is not registered, create the user and return Registered Successfully (this does not log the user in); otherwise return Username already exists, leaving the existing password and login state unchanged. login username password: if the user exists, the password matches and the user is not currently logged in, the login succeeds and returns Logged In Successfully; otherwise return Login Unsuccessful. A logged-in user who logs in again always fails, and the original session stays active. logout username: if the user is currently logged in, log them out and return Logged Out Successfully; if the user does not exist or is not logged in, return Logout Unsuccessful.

Initially there are no users. Usernames and passwords are case-sensitive, users do not affect each other, and a failed request changes no state. It was restored from the original image published on the source page.

输入格式

The first line contains n. Each of the next n lines contains one request: register username password, login username password, or logout username, with fields separated by a single space. 1≤n≤100000; username and password are alphanumeric strings (0-9, a-z, A-Z) of length 1..10. Standard input is this site's adaptation of the string-array parameter.

输出格式

Output n lines; line i is the return value of request i, which is one of Registered Successfully, Username already exists, Logged In Successfully, Login Unsuccessful, Logged Out Successfully, Logout Unsuccessful.

样例 1

输入:

3
register user05 qwerty
login user05 qwerty
logout user05

输出:

Registered Successfully
Logged In Successfully
Logged Out Successfully

样例 2

输入:

5
register david david123
register adam 1Adam1
login david david123
login adam 1adam1
logout david

输出:

Registered Successfully
Registered Successfully
Logged In Successfully
Login Unsuccessful
Logged Out Successfully

样例 3

输入:

8
register Bob pw1
register Bob pw2
login Bob pw2
login Bob pw1
login Bob pw1
logout bob
logout Bob
logout Bob

输出:

Registered Successfully
Username already exists
Login Unsuccessful
Logged In Successfully
Login Unsuccessful
Logout Unsuccessful
Logged Out Successfully
Logout Unsuccessful

样例说明

Original examples 1 and 2 keep their inputs. The fourth output of original example 2 was written as Login Unsuccessfully in the upstream text, which disagrees with Login Unsuccessful in the original table; this site uses Login Unsuccessful as in the table. David in its explanation refers to the input david. registering twice does not overwrite the password, logging in again while logged in fails, and logout bob fails because of the different case.