A. Chat Server's Outgoing Traffic

题目连接:

http://www.codeforces.com/contest/5/problem/A

Description

Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop and implemented a chat server that can process three types of commands:

Include a person to the chat ('Add' command).

Remove a person from the chat ('Remove' command).

Send a message from a person to all people, who are currently in the chat, including the one, who sends the message ('Send' command).

Now Polycarp wants to find out the amount of outgoing traffic that the server will produce while processing a particular set of commands.

Polycarp knows that chat server sends no traffic for 'Add' and 'Remove' commands. When 'Send' command is processed, server sends l bytes to each participant of the chat, where l is the length of the message.

As Polycarp has no time, he is asking for your help in solving this problem.

Input

Input file will contain not more than 100 commands, each in its own line. No line will exceed 100 characters. Formats of the commands will be the following:

+ for 'Add' command.

- for 'Remove' command.

<sender_name>:<message_text> for 'Send' command.

and <sender_name> is a non-empty sequence of Latin letters and digits. <message_text> can contain letters, digits and spaces, but can't start or end with a space. <message_text> can be an empty line.

It is guaranteed, that input data are correct, i.e. there will be no 'Add' command if person with such a name is already in the chat, there will be no 'Remove' command if there is no person with such a name in the chat etc.

All names are case-sensitive.

Output

Print a single number — answer to the problem.

Sample Input

+Mike

Mike:hello

+Kate

+Dmitry

-Dmitry

Kate:hi

-Kate

Sample Output

9

Hint

题意

有一个聊天室

有三种操作:

1.+ xxx 进来一个人

2.- xxx 出去一个人

3.xxx:xxxxx xxx对着所有人说xxxxx,然后这个会对所有人发送一个长度为l的信息。

问你一共发了多长的信息。

题解:

其实根本不用管究竟是谁进来,谁出去。

反正我只关注人数嘛。

代码

#include<bits/stdc++.h>
using namespace std;
int a,b;
string s; int main()
{
while(getline(cin,s))
{
if(s[0]=='+')a++;
else if(s[0]=='-')a--;
else b+=a*(s.size()-s.find(':')-1);
}
cout<<b<<endl;
}

Codeforces Beta Round #5 A. Chat Server's Outgoing Traffic 水题的更多相关文章

  1. Codeforces Beta Round #9 (Div. 2 Only) B. Running Student 水题

    B. Running Student 题目连接: http://www.codeforces.com/contest/9/problem/B Description And again a misfo ...

  2. Codeforces Beta Round #9 (Div. 2 Only) A. Die Roll 水题

    A. Die Roll 题目连接: http://www.codeforces.com/contest/9/problem/A Description Yakko, Wakko and Dot, wo ...

  3. Codeforces Beta Round #3 A. Shortest path of the king 水题

    A. Shortest path of the king 题目连接: http://www.codeforces.com/contest/3/problem/A Description The kin ...

  4. CodeForces.5A Chat Server's Outgoing Traffic

    Chat Server's Outgoing Traffic 点我挑战提目 考察点 模拟 字符串 Time Mem Len Lang 30 0 543 c++ 题意分析 给出类似一个群的即时通讯系统, ...

  5. Chat Server's Outgoing Traffic

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93359#problem/A (456321) http://codeforces.com ...

  6. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  7. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  8. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  9. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

随机推荐

  1. oracle 归档模式、补充日志

    1.归档模式: Oracle数据库有联机重做日志,这个日志是记录对数据库所做的修改,比如插入,删除,更新数据等,对这些操作都会记录在联机重做日志里.一般数据库至少要有2个联机重做日志组.当一个联机重做 ...

  2. Cookie、Session 和 自定义分页

    cookie Cookie的由来 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它不会受前面的请求响应情况直接影响,也不 ...

  3. 【Linux学习】python脚本直接运行与nohup运行结果不同

    之前遇到问题,在云主机上运行python脚本直接运行与nohup运行结果不同,甚至nohup根本运行不出来. 后来参考下别人的博客,终于知道问题了. nohup 使用的python版本问题. 而且no ...

  4. 014 JVM面试题

    转自:http://www.importnew.com/31126.html 本文从 JVM 结构入手,介绍了 Java 内存管理.对象创建.常量池等基础知识,对面试中 JVM 相关的基础题目进行了讲 ...

  5. 004ICMP-type对应表

    一次在某个防火墙配置策略里看到如下的代码: iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT iptables -A FORWARD -p icmp ...

  6. ECharts图表tooltip显示时超出canvas图层解决方法

    我们在做ECharts图表的时候可能会遇到tooltip显示时超出了canvas图层范围,并且被其它z-index较高的div容器遮盖,这是悬浮展示信息就看不全,我们根据官网文档的配置项查询发现con ...

  7. yolo回归型的物体检测

    本弱又搬了另外一个博客的讲解: 缩进YOLO全称You Only Look Once: Unified, Real-Time Object Detection,是在CVPR2016提出的一种目标检测算 ...

  8. 让MySql支持Emoji表情存储

    java后台报错,如下. aused by: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x84' for column ...

  9. Python抓取微博评论(二)

    对于新浪微博评论的抓取,首篇做的时候有些考虑不周,然后现在改正了一些地方,因为有人问,抓取评论的时候“爬前50页的热评,或者最新评论里的前100页“,这样的数据看了看,好像每条微博的评论都只能抓取到前 ...

  10. Linux下软件的安装与管理

    1.源码安装方式 2.RPM包方式安装 3.yum安装方式 4.二进制软件安装方式 1.源码安装方式 (1)下载.解压Apache源码: mkdir /apache #在根目录下创建一个apache目 ...