5-27 QQ Account Management (25 points)
You is supposed to implement the functions's account "Log in" and "Register" for the most popular instant Messager QQ. T He most challenging part was that QQ now have more than a billion users.
Input Specification:
Each input file contains the one test case. For each case, the first line contains an integer N (≤105\le 10^5≤10
5
)-The total number of queries. Then N lines follow, each contains a query in the format command qq_no Password where command was either R (meaning to Regi Ster a new account, and hence followed by a new account number and a password), or L (meaning to log in with a existing a Ccount, and hence followed by the account number and the password); Qq_no is a integer that's greater than and No more than digits long; And Password is a string with no less than 6 and no more than-characters without any space.
Output Specification:
For each of the test case, print the corresponding message to each query in a line. The messages are:
If a new account is successfully registered, output "Register successful";
if the new registering account number already exists, output "Error:account number already exists";
if log in successfully with output "log in successful";
if the ' log in ' does not exist, output ' error:account not exist ';
if log in with a wrong password, output "Error:wrong password".
Sample Input:
5
L 1234567890 myQQ@qq.com
R 1234567890 myQQ@qq.com
R 1234567890 myQQ@qq.com
L 1234567890 MYQQ@QQ
L 1234567890 myQQ@qq.com
Sample Output:
Error:account not Exist
Register Successful
Error:account number already Exists
Error:wrong Password
Log in successful
This is the coincidence of the teammates with a map
with an array record number, and then the number map to the input I, the input mailbox is directly recorded with a two-bit array, and then the array record number map to the I, is directly a two-dimensional array of I, very good.
#include <bits/stdc++.h> using namespace std;
typedef long Long LL;
typedef unsigned long long ULL;
const double eps=1e-5;
Const double Pi=acos (-1.0);
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
#define MAX 100010 int n,m;
Char C1;
Char pass[max][21];
ll A[max];
int main () {map < ll, int >q;
int t,i,j,k;
scanf ("%d", &n);
GetChar ();
int num1=0;
for (I=1; i<=n; i++) {ll B;
int flag=0;
scanf ("%c", &C1);
scanf ("%lld%s", &a[i],pass[i]);
GetChar ();
if (c1== ' R ') {if (q[a[i]]>0) printf ("Error:account number already exists\n");
else {printf ("Register successful\n");
Q[a[i]]=i; }} if (c1== ' L ') {if (A[q[a[i]]]==a[i]) {if (strcmp (pass[q[
A[i]]],pass[i]) ==0) printf ("Log in successful\n"); ElsE printf ("Error:wrong password\n");
} else if (a[q[a[i]]]==0) printf ("Error:account No ' exist\n");
}} return 0;
}