Codeforces 705C Thor (模拟)

基于Python的上市公司年报PDF文本抓取与财务风险分析系统 随着大数据时代的到来,金融数据分析已成为投资决策和风险管理的重要工具。上市公司年报包含了丰富的财务信息和经营数据,通过对这些数据的提取和分析,可以评估公司的财务状况和潜在风险。本文将详细介绍如何使用Python构建一个完整的上市公司年报文本抓取与财务风险分析系统,涵盖PDF文本提取、数据清洗、财务指标计算和风险分析等全流程。 阅读详情

http://www.codeforces.com/contest/705/problem/C

Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can’t count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can’t).

q events are about to happen (in chronological order). They are of three types:

Application x generates a notification (this new notification is unread).
Thor reads all notifications generated so far by application x (he may re-read some notifications).
Thor reads the first t notifications generated by phone applications (notifications generated in first t events of the first type). It's guaranteed that there were at least t events of the first type before this event. Please note that he doesn't read first t unread notifications, he just reads the very first t notifications generated on his phone and he may re-read some of them in this operation. 

Please help Thor and tell him the number of unread notifications after each event. You may assume that initially there are no notifications in the phone.

Input

The first line of input contains two integers n and q (1 ≤ n, q ≤ 300 000) — the number of applications and the number of events to happen.

The next q lines contain the events. The i-th of these lines starts with an integer typei — type of the i-th event. If typei = 1 or typei = 2 then it is followed by an integer xi. Otherwise it is followed by an integer ti (1 ≤ typei ≤ 3, 1 ≤ xi ≤ n, 1 ≤ ti ≤ q).

Output

Print the number of unread notifications after each event.

Examples
Input
3 4
1 3
1 1
1 2
2 3

Output
1
2
3
2

Input
4 6
1 2
1 4
1 2
3 3
1 3
1 3

Output
1
2
3
0
1
2


题意简化相当于:
有三种操作,第一种操作是 将 x值 插入到容器的末尾;第二种操作是 将 容器中 的 x值 全部标记; 第三种操作是 将容器中前 x 个数标记。 标记过得可重复标记。问每个操作做完后有多少个数没有被标记。

解题思路:
用容器直接模拟,T了好久。加优化也T。
后来开个pre[]数组记录x值得前面一个x值在哪个地方。
这种pre[] , next[]的方法要熟记…


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 3*1e5 + 100;
int arr[N], tail[N], pre[N], vis[N];
int main()
{
        int n,q,id = 0,sum=0,last = 0;
        scanf("%d%d",&n,&q);
        memset(tail,-1,sizeof(tail));
        memset(pre,-1,sizeof(pre));
        while(q--)
        {
                int op,x;
                scanf("%d%d",&op,&x);
                if(op==1)
                {
                        pre[++id] = tail[x];
                        tail[x] = id;
                        sum++;
                }
                else if(op==2)
                {
                        int tmp = tail[x];
                        while(tmp!=-1 && !vis[tmp])
                        {
                                vis[tmp] = true;
                                tmp = pre[tmp];
                                sum--;
                        }
                }
                else
                {
                        for(int i = last+1; i<=x;i++)
                        {
                               if(!vis[i]) 
                               {
                                       sum--;
                                       vis[i] = true;
                               }
                        }
                        last = max(last,x); 
                }
                printf("%d\n",sum);
        }
        return 0;
}
# YOLOv11-seg改进系列 | 引入CVPR MetaFormer的C3k2_PoolingFormerCGLU模块,池化Token混合+CGLU门控MLP 本文引入 CVPR 2022 论文(MetaFormer/PoolFormer)提出的 MetaFormer 元架构设计,以Pooling Token 混合器 + ConvolutionalGLU(CGLU)MLP构成,将其封装为,用于替换 YOLOv11-seg 的 C3k2 块。对比维度C3k2(基线)C3k2_PoolingFormerCGLU(本文)参数量(n scale)2.46M≈2.49M9.6≈9.69.7(+1.0%)架构范式单阶段卷积MetaFormer 双阶段。 阅读详情

相关推荐

Ubuntu登录界面黑屏?手把手教你排查和修复lightdm启动失败(附debug命令详解)

本文详细介绍了Ubuntu登录界面黑屏问题的排查与修复方法,重点解决lightdm启动失败问题。通过提供紧急应对措施、深度诊断命令和五大常见故障点的修复方案,帮助用户快速恢复图形界面。文章还包含高级修复技巧和预防措施,确保系统稳定运行。

weixin_33067503的博客 273

CodeForces 1721B【思维】【模拟】

【代码】CodeForces 1721B【思维】【模拟】

willem248的博客 250

折叠式共源共栅运放设计实战:Cadence Virtuoso完整流程

在模拟IC设计中,运放是信号链的核心模块,而共源共栅结构凭借高增益、高输出阻抗的特性,成为高性能放大器的经典选择。其中,折叠式共源共栅运放通过电流折叠技术,在不牺牲增益的前提下显著改善输出摆幅与输入共模范围,尤其适合1.8V低压工艺下的高动态范围应用。本文从共源共栅放大器的基本原理出发,解析其技术价值与典型应用场景,并基于0.18μm工艺,系统展示如何利用Cadence Virtuoso完成从电路结构分析、管子尺寸推导到原理图绘制、仿真调试的完整设计闭环。内容涵盖增益、带宽、相位裕度等关键指标的优化方法,以

weixin_34277853的博客 385

快乐补题-SDNU_ACM_ICPC_2020_Winter_Practice_1st——F

Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can’t count the numbe...

lumingran的博客 481

基于yolov5的鸟类图像准确识别

本项目主要基于yolov5进行鸟类准确识别,主要识别白鹭家族,红脚鹬,反嘴鹬,环颈珩,小白鹭以及夜鹭六类鸟

weixin_46064184的博客 3828

批量处理|基于ENVI的遥感影像批量自动配准工具

遥感影像图像配准(Image Registration)就是将不同时间、不同传感器(成像设备)或不同条件下(天候、照度、摄像位置和角度等)获取的两幅或多幅图像进行匹配、叠加的过程。 ENVI软件自带的Image Registration Workflow是一个自动、准确、快速的影像配准工作流,它将繁杂的参数设置步骤集成到统一的面板中,在少量或者无需人工干预的情况下能快速而准确的实...

海洋GISer成长记 6333

Codeforces Round #366 (Div. 2) C. Thor (队列模拟)

C. Thortime limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputThor is getting used to the Earth. As a gift Loki gave him a smartphone. There

滴水穿石,慢慢积累,总会有成果 625

S32DS使用完整指南:S32K CAN通信模块配置步骤

深入讲解S32DS使用过程中S32K芯片的CAN通信模块配置步骤,涵盖关键设置与常见问题。掌握s32ds使用技巧,提升开发效率,实现稳定可靠的车载网络通信。

weixin_42592399的博客 997

Codeforces Round #823 (Div. 2)(A~D)(模拟,二分,数学,字符串构造)

Codeforces Round #823 (Div. 2)(A~D)

zy98zy998的博客 532

【30天从零玩转AI应用开发】第16篇:智能体Agent入门——ReAct框架原理+首个会思考、会动手的AI实战

摘要: 本文介绍了AI智能体(Agent)的核心概念及其与普通大模型(LLM)的区别。通过ReAct(Reason+Act)框架,智能体实现了自主思考、调用工具和分步执行的能力。文章详细讲解了LangChain Agent的四大组件,并推荐新手使用ZERO_SHOT_REACT_DESCRIPTION类型。最后提供了一个完整的智能体实战代码示例,该智能体具备数学计算和天气查询功能,能够自主选择工具完成任务,展示了AI从”被动回答“到”主动行动“的关键进化。

在上海谋生的软件喵记录喵生 635

电路中的DGND、GROUND、GROUND_REF的区别,VREF、VCC、VDD、VEE和VSS的区别?

DGND是数字地,是数字电路部分的公共基准端,用于连接数字电路的接地。

XU157303764的博客 2373

codeforces div3 D (模拟)

题目 题意: 给定一个长度为n的数组,数组中元素大小为[-2,2].数组的贡献为数组中所有元素乘积的乘积,可以删除任意数量的元素,使得数组贡献最大。不要求删除的数量最少,找出任意解即可。空数组贡献为1。 思路: 模拟。 (1)不存在0,判断负数出现次数的奇偶性即可。如果是奇数,判断从左边删更优还是从右边删更优。 (2)存在0。如果全是0,那就全删除。 如果不全是0,会发现只能保留一小段两个0之间的数。否则的话有0一乘就变成0了。所以每一小段仿照(1)检查一下谁更优即可。 时间复杂度: O(n) 代码: //

xianqiuyigedao的博客 370

华为OD机考双机位C卷 - 风险投资计划(Java & Python& JS & C/C++ & GO )

华为OD机考双机位C卷 - 风险投资计划(OD上机考试双机位C卷)。提供Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。

算法大师! 554

【模拟】Codeforces 704A & 705C Thor

题目链接:   http://codeforces.com/problemset/problem/704/A   http://codeforces.com/problemset/problem/705/C 题目大意:   雷神有N个应用,接下来Q个操作,操作分三种   1.应用X增加一个未读消息。   2.把应用X的未读消息全都读了。(可能重复读了已读的)

Coolxxx的博客 564

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

CodeForces 705C Thor (模拟)

C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Thor is getting used to the Earth. As a gift Loki g

Calm微笑 697

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

CodeForces - 705C Thor (模拟)

Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the numbe...

。 355

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

codeforces 705C C. Thor(模拟)

题目链接: C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Thor is getting used to the Earth. As a gift Loki ga...

weixin_30650039的博客 155

【CodeForces - 705C】Thor(模拟,STLset优化链表)

题干: Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There arenapplications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the ...

xuanweiace的博客 551

CodeForces - 705C Thor (数组模拟队列)

Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the n...

weixin_30922589的博客 160

CodeForces 705C

C. Thor Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can’t count t...

给我一把键盘 293

CodeForces705C、Thor (STL)

C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Thor is ge...

Amove 562

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

http://codeforces.com/contest/705/problem/C题目 模拟题 : 设的方法采用一个 r 数组(第几个app已经阅读过的消息的数量),和app数组(第几个app发出的消息的总数),加上一个 q 队列。 思路: 查询==1的时候,入队(记录顺序), sum++ (sum 为全部的剩余 没阅读的数量) 查询==2的时候,针对一个...

ampg66396的博客 121

【Codeforces Round #366 Div. 2】 705C Thor

模拟

Orion_Rigel 479

CodeForces 705C Thor

开30W个vector将数字归类,每一类数字开一个指针P,记录已经阅读到哪一个了,还可以开一个优先队列维护这些指针P。 #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include...

weixin_34228387的博客 122

Codeforces Round #366 (Div. 2) C. Thor (模拟)*

题目链接:http://codeforces.com/contest/705/problem/C 题意: input 4 6 1 2 1 4 1 2 3 3 1 3 1 3 output 1 2 3 0 1 2 以第二个样例为例,第一行n和q,n表示某手机有n个app,q表示下面有q个操作。 操作类型1:app x增加一条未读信息。 操作类

Benjamin_Z的博客 737

Codeforces Round #366 (Div. 2) Thor

题目链接:http://codeforces.com/contest/705/problem/C 比赛的时候莫名其妙的WA第四组数据,不知道为什么,比赛结束之后看数据,第四组数据量太大也不大想看,把之前写的vector改成queue,数组用的set集合,然后再交就过了……应该是哪里写丑了。 思路就是存储所有的数据在set集合中,通过不听的删除和增加来进行计算。 #includ

RaAlGhul的博客 504
上一篇: HDU 5835 Danganronpa(贪心)
下一篇: Codeforces 703D Mishka and Interesting sum (树状数组求区间内不同的数的异或和)
WANSNIM
博客等级 码龄12年 27粉丝 101原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址