5-27 QQ Account Management (25分)

You are supposed to implement the functions of account “Log in” and “Register” for the most popular instant messager QQ. The most challenging part is that QQ now has more than a billion users.

Input Specification:

Each input file contains 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 is either R (meaning to register a new account, and hence followed by a new account number and a password), or L (meaning to log in with an existing account, and hence followed by the account number and the password); QQ_No is an integer that is greater than 1000 and no more than 10 digits long; and Password is a string with no less than 6 and no more than 16 characters without any space.

Output Specification:

For each test case, print the corresponding message for 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, output “Log in Successful”;

•If the log in account 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

这是队友的巧用map

用一个数组记录编号,然后编号映射到输入的i,输入的邮箱直接是用二位数组记录的,然后数组记录的编号映射到的 i ,直接是二维数组中的 i ,非常棒。

#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;
}

最新文章

  1. ASP.NET Core 中文文档 第四章 MVC(4.5)测试控制器逻辑
  2. Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误
  3. C语言编译过程
  4. DEDECMS之八 漏洞错误和疑难杂症
  5. jquery this 与javascript的this
  6. 使用复合索引代替单键索引,来避免单键有null值的情况
  7. COSBench性能测试配置--一张图说明一切
  8. ajax返回值给上层函数的方法。
  9. SELINUX设为Disable 影响java SSH工具包Jsch 0.1.49.jar的一个案例
  10. 使用Windows Azure创建和发布ASP.NET应用程序
  11. HDU 3313 Key Vertex(dfs + bfs)
  12. C#开发ActiveX控件
  13. Redis Sentinel中的机制与原理详解
  14. bzoj:2018 [Usaco2009 Nov]农场技艺大赛
  15. beautifulsoup库使用
  16. Android电话拦截实现以及TelephonyManager监听的取消
  17. 二分搜索树实现Java的Map(下)
  18. MacBook Air 装win10系统 by DODUI
  19. 调用shutdown.sh后出现could not contact localhost8005 tomcat may not be running报错问题
  20. 关于react16.4——转发refs和片段Fragment

热门文章

  1. C#如何实现挂机锁
  2. POJ 3518 Prime Gap(素数)
  3. Leetcode41: Remove Duplicates from Sorted List
  4. 程序的载入和运行(五)——《x86汇编语言:从实模式到保护模式》读书笔记25
  5. C#语言 ArrayList集合
  6. HDU 1284 钱币兑换问题 (完全背包)
  7. Linux环境下如何查找哪个线程使用CPU最长
  8. Spring Batch(4): Job具体解释
  9. Java 复杂excel报表导出
  10. FLTK 简介