PTA QQ Account Managememap the ingenious due

Source: Internet
Author: User

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", &AMP;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;
 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.