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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Codeforces #366 Div. 2 C. Thor (模拟

    http://codeforces.com/contest/705/problem/C 题目 模拟题 : 设的方法采用一个 r 数组(第几个app已经阅读过的消息的数量),和app数组(第几个app发 ...

  5. 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 ...

  6. 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 ...

  7. Codeforces Round #366 Div.2[11110]

    这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...

  8. 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 ...

  9. 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. JavaWeb学习记录(二十二)——模式字符串与占位符

    一.Java代码案例 @Test    public void test10(){        int planet=7;        String event="a disturban ...

  2. Quailty and Binary Operation

    Quailty and Binary Operation 题意 分别给\(N,M(N,M \le 50000)\)两个数组\(A\)和\(B\),满足\(0 \le A_i,B_i \le 50000 ...

  3. Android——多线程编程练习题

    随便选择两个城市作为预选旅游目标.实现两个独立的线程分别显示10次城市名,每次显示后休眠一段随机时间(1000ms以内),哪个先显示完毕,就决定去哪个城市.分别用Runnable接口和Thread类实 ...

  4. 使用jquery插件实现图片延迟加载技术(懒加载)

    有时我们看到一些大型网站,页面如果有很多图片的时候,当你滚动到相应的行时,当前行的图片才即时加载的,这样子的话页面在打开只加可视区域的图片,而其它隐藏的图片则不加载,一定程序上加快了页面加载的速度,对 ...

  5. kuangbin_ShortPath L (POJ 2502)

    dij部分还是跟模板差不多的 但是这题的难点是处理输入 或者说理解题意 事实上每个点之间都是可以走的......WA了好几发就因为没意识到同一条路线上的各个站点之间居然也可以走得比车子快.... PS ...

  6. 黑马程序员——JAVA基础之多线程的线程间通讯等

    ------- android培训.java培训.期待与您交流! ---------- 线程间通讯: 其实就是多个线程在操作同一个资源,但是动作不同. wait(); 在其他线程调用此对象的notif ...

  7. NetStatusEvent info对象的状态或错误情况的属性

      代码属性 级别属性 意义 "NetStream.Buffer.Empty" "status"  数据的接收速度不足以填充缓冲区.数据流将在缓冲区重新填充前中 ...

  8. SSRS入门相关笔记

    1.SSRS Server 的地址的查看及设置:打开 开始->程序-> Microsoft SQL Server 2012/2014 -> Configuration Tools - ...

  9. 009. C#中的WebBrowser控件的属性、方法及操作演示代码(转)

    本文转自 http://www.open-open.com/code/view/1430559996802 0.常用方法 Navigate(string urlString):浏览urlString表 ...

  10. 【转】第4篇:Xilium CefGlue 关于 CLR Object 与 JS 交互类库封装报告:委托回调方法分析

    作者: 牛A与牛C之间 时间: 2013-11-18 分类: 技术文章 | 暂无评论 | 编辑文章 主页 » 技术文章 » 第4篇:Xilium CefGlue 关于 CLR Object 与 JS ...