Codeforces Round #366 (Div. 2) C Thor(模拟+2种stl)
Thor
题意:
第一行n和q,n表示某手机有n个app,q表示下面有q个操作。
操作类型1:app x增加一条未读信息。
操作类型2:一次把app x的未读信息全部读完。
操作类型3:按照操作类型1添加的顺序,按顺序读t条信息,注意这t条信息可能有的已经读过。如果读过也算前t条,会再读一遍。
最后输出每次操作有多少信息没读。
题解:
一看题,要30W,那肯定不可以n^2了,想一想,3种操作,一个vector够用吗,应该不够,所以再加个set,就差不多了。那么思路就是这样的:
首先要有个计数器cnt,从1开始,他的作用是为了第3个操作的,这样就可以知道那些是前x个了,就不会多删掉。之后vei[x]放cnt,如果2操作,就先根据vei[x][0]~vei[x][vei.size()]把set里的删去,之后在vei[x].claer()就好了。
代码:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300000 + 9 ;
vector<int>vei[MAXN];
set<int>sei;
int n, q, a, x, cnt = 1;
int main()
{
cin >> n >> q;
for(int i = 0; i < q; i++)
{
cin >> a >> x;
if(a == 1)
{
vei[x].push_back(cnt);
sei.insert(cnt++);
}
else if(a == 2)
{
for(int j = 0; j < vei[x].size(); j++)
{
sei.erase(vei[x][j]);
}
vei[x].clear();
}
else
{
while(1)
{
if(*sei.begin() > x || sei.empty()) break;
else sei.erase(*sei.begin());
}
}
cout << sei.size() << endl;
}
return 0;
}
Codeforces Round #366 (Div. 2) C Thor(模拟+2种stl)的更多相关文章
- Codeforces Round #366 (Div. 2) C. Thor (模拟)
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #366 (Div. 2)_C. Thor
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces #366 Div. 2 C. Thor (模拟
http://codeforces.com/contest/705/problem/C 题目 模拟题 : 设的方法采用一个 r 数组(第几个app已经阅读过的消息的数量),和app数组(第几个app发 ...
- Codeforces Round #366 (Div. 2) C 模拟queue
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #366 (Div. 2) A , B , C 模拟 , 思路 ,queue
A. Hulk time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- Codeforces Round #366 Div.2[11110]
这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...
- Codeforces Round #301 (Div. 2)(A,【模拟】B,【贪心构造】C,【DFS】)
A. Combination Lock time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- Codeforces Round #345 (Div. 2)【A.模拟,B,暴力,C,STL,容斥原理】
A. Joysticks time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
随机推荐
- 1-2 ISO/OSI七层模型简介
相关名词解释: ISO:国际标准化组织 OSI:开放系统互联模型 IOS:苹果操作系统, 但是在计算机网络中,IOS是互联网操作系统,是思科公司为其网络设备开发的操作维护系统 <1>OSI ...
- MySQL性能参数详解 - max_connect_errors
max_connect_errors是一个MySQL中与安全有关的计数器值,它负责阻止过多尝试失败的客户端以防止暴力破解密码的情况.max_connect_errors的值与性能并无太大关系. 默认情 ...
- UVA-11468 Substring(AC自动机+DP)
题目大意:给一些模板串,一些字符的出现概率.问不会出现模板串的概率是多少. 题目分析:是比较简单的概率DP+AC自动机.利用全概率公式递推即可. 代码如下: # include<iostream ...
- liunx之:wps for liunx的安装经验
首先是下载正确的安装包 WPS For Linux : 社区下载:http://community.wps.cn/download/ 社区最新包下载:http://wps-community.org/ ...
- c3p0操作MySQL数据库
使用c3p0连接MySQL数据库并对MySQL数据库进行基本操作. 1. [文件] 数据库准备 ~ 226B 下载(64) ? 1 2 3 4 5 6 7 8 9 10 ##创建数据库 ...
- 纯CSS绘制三角形(各种角度)
我们的网页因为 CSS 而呈现千变万化的风格.这一看似简单的样式语言在使用中非常灵活,只要你发挥创意就能实现很多比人想象不到的效果.特别是随着 CSS3 的广泛使用,更多新奇的 CSS 作品涌现出来. ...
- 市委组织部考核项目——利用EasyUi中可编辑的DataGrid控件对多行数据进行编辑并提交
http://blog.csdn.net/cjr15233661143/article/details/19041165 市委组织部考核项目中需要录入原始数据,拿开发区的数据录入举例说明,见下图,需要 ...
- eclipse 怎么新建工作空间workspace
打开eclipse 点击文件“File”菜单切换工作空间“Switch Workspace”>其它“Other” 点击“Browser”选择新的工作空间目录. 选择新的工作空间目录,点击确定. ...
- DW(三):polybase基本理论
PolyBase is a technology that accesses and combines(整合) both non-relational and relational data, all ...
- 【redis】 linux 下redis 集群环境搭建
Redis集群 (要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如下) 127.0.0.1:63791 ...