Codeforces Beta Round #5 A. Chat Server's Outgoing Traffic 水题
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 水题的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- CodeForces.5A Chat Server's Outgoing Traffic
Chat Server's Outgoing Traffic 点我挑战提目 考察点 模拟 字符串 Time Mem Len Lang 30 0 543 c++ 题意分析 给出类似一个群的即时通讯系统, ...
- Chat Server's Outgoing Traffic
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93359#problem/A (456321) http://codeforces.com ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- 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]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
随机推荐
- redhat5.5 x64 安装oracle 11g
http://www.cnblogs.com/jamesf/p/4769086.html http://blog.csdn.net/yakson/article/details/9012129
- perl6 一个猜测密码的注入
use HTTP::UserAgent; my $ua = HTTP::UserAgent.new; my $r = HTTP::Request.new; my $c = HTTP::Cookies. ...
- Homestead在windows7 下的搭建
遇到的问题有 1.Homestead 的版本问题,教程git版本是 v5,最新是v7的,如果用最新,就要求vagrant的版本是 2.0的: 2.启动homestead后,出现 No input fi ...
- [ python ] 进程的操作
目录 (见右侧目录栏导航)- 1. 前言- 2. multiprocess模块- 2.1 multiprocess.Process模块 - 2.2 使用Process模块创建进程 - 2. ...
- 转:PHP环境搭建 - Linux
本文PHP环境采用,nginx + PHP7 + mysql 5.6 一.安装mysql 5.6 参见:http://www.cnblogs.com/rslai/p/7853465.html 二.Ng ...
- Delphi 绘图对象
来自:http://blog.csdn.net/lailai186/article/details/8755430 ========================================== ...
- beego学习笔记(2)
BEEGO的几个特点: 简单化 RESTful 支持.MVC 模型,可以使用 bee 工具快速地开发应用,包括监控代码修改进行热编译.自动化测试代码以及自动化打包部署. 智能化 支持智能路由.智能监控 ...
- 自组织神经网络介绍:自组织特征映射SOM(Self-organizing feature Map),第三部分
前面两篇介绍了SOM的基本概念和算法,第一部分,第二部分,本篇具体展开一下应用中的一些trick设定. SOM设计细节 输出层设计 输出层神经元数量设定和训练集样本的类别数相关,但是实际中我们往往不能 ...
- MIAC HW2
MIAC的第二次作业,翻了一些fashion网站找了点灵感,重新设计了一下UI. 因为给的html里有nav之类的HTML5新特性,所以索性就不管IE的兼容了.chrome下的效果: FF下也差不多. ...
- PhpStorm设置函数注释模板
*设置位置:"Settings"->"file templates"; 如下图,设置头部注释.类注释以及函数注释,时间.用户名.文件名称等随机改变的属性, ...