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. Dynamics CRM 2015/2016 Web API:新的数据查询方式

    今天我们来看看Web API的数据查询功能,尽管之前介绍CRUD的文章里面提到过怎么去Read数据,可是并没有详细的去深究那些细节,今天我们就来详细看看吧.事实上呢,Web API的数据查询接口也是基 ...

  2. Variable 'bop' is uninitialized when captured by block

    代码: - (void)doTest { NSBlockOperation * bop = [NSBlockOperation blockOperationWithBlock:^{ if (!bop. ...

  3. 阿里云 ubuntu 14.04 模板上安装 docker

    ubuntu 14.04 的内核是 3.13 ,所以内核不用升级. 安装过程例如以下: # apt-get update # apt-get install apt-transport-https # ...

  4. mtk机型的一次救砖经历

    在recovery里清除了data,cache,system三个分区,没有刷机,重启到bootloader,准备另刷recovery. 有急事走开了,回来时发现手机黑屏,无论什么组合键都没反应,以为是 ...

  5. linux进程间通信消息队列:msgsnd: Invalid argument

    今天写了个消息队列的小测试程序结果send端程序总是出现:msgsnd: Invalid argument,搞了半个小时也没搞明白,后来查资料发现我将(st_msg_buf.msg_type = 0; ...

  6. 1507: [NOI2003]Editor

    1507: [NOI2003]Editor Time Limit: 5 Sec  Memory Limit: 162 MB Submit: 3535  Solved: 1435 [Submit][St ...

  7. 关闭SVN服务

    关闭TSVNCache.exe进程 在Windows下使用SVN,通常都会安装TortoiseSVN,安装后会有一个TSVNCache.exe的进程驻留内存,这个进程会定时地去扫描Subversion ...

  8. 常见mysql分布式数据中间件

    一般分为三种: 1. proxy sharding,目前由cobar,mycat,drds,atlas修改,这几个产品的起源一般是mysqlproxy 或 ameoba,特点是mysql协议基本兼容, ...

  9. [git] csdn之code平台的使用

    简单的说一下GIT的使用.... 代码和托管平台是csdn刚出来没多久的code.csdn.net [中文的界面什么的简单点,好理解,嗯,易用....] Git 使用最新版:Git-1.8.4-pre ...

  10. 区分虚拟机和machine simulator

    1 虚拟机和machine simulator的不同 虚拟机是让多个操作系统同时共用现有的硬件架构,它不会模拟新的硬件架构.qemu这样的模拟器是模拟新的硬件架构,这个架构和host不同.