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

PTA QQ Account Manageme【map的巧妙应有】的更多相关文章

  1. QQ现状深度剖析:你还认为QQ已经被微信打败了吗?

    本文来自“人人都是产品经理”公众号作者栗栗粥的原创分享. 1.前言   移动端的时代里,微信占据了社交领域的半壁江山,不得不让人想起曾经PC时代里的王者“QQ”,微信的爆发和QQ的停滞让很多人认为微信 ...

  2. java基础50 配置文件类(Properties)

    1. 配置文件类Properties的概念 主要生产配置文件与读取配置文件的信息 2.Properties要注意的细节 1.如果配置文件一旦使用了中文,那么在使用store方法生产的配置文件额时候字符 ...

  3. Python与数据库[2] -> 关系对象映射/ORM[5] -> 利用 sqlalchemy 实现关系表查询功能

    利用 sqlalchemy 实现关系表查询功能 下面的例子将完成一个通过关系表进行查询的功能,示例中的数据表均在MySQL中建立,建立过程可以使用 SQL 命令或编写 Python 适配器完成. 示例 ...

  4. DS博客作业07——查找

    1.本周学习总结 1.1思维导图 1.2.谈谈你对查找运算的认识及学习体会. 查找的内容和前两章树和图相比,要简单许多,在二次搜索树虽然也要用到树,但是也是很简单的树的操作,再加上查找的代码可以使用m ...

  5. python 多线程,tthread模块比较底层,而threading模块是对thread做了一些包装,multithreading

    Python多线程详解 2016/05/10 · 基础知识 · 1 评论· 多线程 分享到:20 本文作者: 伯乐在线 - 王海波 .未经作者许可,禁止转载!欢迎加入伯乐在线 专栏作者. 1.多线程的 ...

  6. Spring MVC学习

    SpringMVC框架 转载请注明出处 目录 一:配置springMVC开发环境 1.1.配置文件的helloworld 1.2.基于注解的helloworld 二:@RequestMapping详解 ...

  7. RedisUtil 工具类

    package com.test; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import red ...

  8. 跟我一起数据挖掘(21)——redis

    什么是Redis Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年3月15日起,Redis的开发工 ...

  9. iOS开发之功能模块--本地序列化

    下面只展示项目开发中,本地序列化的示例代码: AuthenticationManager.h #import <Foundation/Foundation.h> #import " ...

随机推荐

  1. 微信小程序 项目实战(二)board 首页

    1.项目结构 2.页面 (1)数据(逻辑) board.js // pages/board/board.js Page({ /** * 页面的初始数据 */ data: { imgWrap: [] } ...

  2. 【转载】一分钟了解两阶段提交2PC(运营MM也懂了)

    上一期分享了"一分钟了解mongoDB"[回复"mongo"阅读],本期将分享分布式事务的一种实现方式2PC. 一.概念 二阶段提交2PC(Two phase ...

  3. 【翻译自mos文章】多租户中的service管理

    来源于: Service Management For Multitenant (文档 ID 2009500.1) APPLIES TO: Oracle Database - Enterprise E ...

  4. 关于Android滑动冲突的解决方法(二)

    之前的一遍学习笔记主要就Android滑动冲突中,在不同方向的滑动所造成冲突进行了了解,这样的冲突非常easy理解,当然也非常easy解决.今天,就同方向的滑动所造成的冲突进行一下了解,这里就先以垂直 ...

  5. appium支持的版本

    appium 支持4.2以上的版本 2.3-4.1的版本的支持通过Selendroid实现

  6. struct与 union的基本用法

    结构体与联合体是C语言的常见数据类型,可对C的基本数据类型进行组合使之能表示复杂的数据结构,意义深远,是优异代码的必备工具.一.        struct与 union的基本用法,在语法上union ...

  7. react native 中的redux 理解

    redux 中主要分为三大块,分别是Action Reducer 与Store. 1.Action是js的一个普通对象,是store数据的唯一来源.通过store.dispath()讲action传到 ...

  8. HDU 1022 之 Train Problem I

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. Spring Boot2.0之整合Redis

    需要的maven依赖 jar包,是对Jedis的封装 maven依赖: <project xmlns="http://maven.apache.org/POM/4.0.0" ...

  10. 虚拟机bridged, NAT and host-only网络区别

    In Linux, a network of each type is created when running vmware-config.pl. In Windows, they are auto ...