CodeForces - 527C Glass Carving(STL)

Ansys Icepak:通过 ECAD 导入和非共形网格划分掌握电子冷却 通过将 Icepak 与 HFSS(用于高频电磁学)、Ansys Mechanical(用于结构分析)和 Ansys Fluent(用于流体动力学)等 Ansys 产品相结合,工程师可以在单个工作流程中仿真电子系统的完整行为,从热和电气动力学到机械和流体动力学。精细网格可以应用于关键区域,而在不太重要的区域使用较粗的网格,从而在不牺牲精度的情况下加快仿真速度。这些功能使 Ansys Icepak 成为从事复杂电子设计的工程师不可或缺的工具,可实现更精确的热分析并缩短开发时间。用于高效仿真的非共形网格划分。 阅读详情

Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm  ×  h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.

In order not to waste time, he decided to practice the technique of carving. To do this, he makes vertical and horizontal cuts through the entire sheet. This process results in making smaller rectangular fragments of glass. Leonid does not move the newly made glass fragments. In particular, a cut divides each fragment of glass that it goes through into smaller fragments.

After each cut Leonid tries to determine what area the largest of the currently available glass fragments has. Since there appear more and more fragments, this question takes him more and more time and distracts him from the fascinating process.

Leonid offers to divide the labor — he will cut glass, and you will calculate the area of the maximum fragment after each cut. Do you agree?

Input

The first line contains three integers w, h, n (2 ≤ w, h ≤ 200 000, 1 ≤ n ≤ 200 000).

Next n lines contain the descriptions of the cuts. Each description has the form H y or V x. In the first case Leonid makes the horizontal cut at the distance ymillimeters (1 ≤ y ≤ h - 1) from the lower edge of the original sheet of glass. In the second case Leonid makes a vertical cut at distance x (1 ≤ x ≤ w - 1) millimeters from the left edge of the original sheet of glass. It is guaranteed that Leonid won't make two identical cuts.

Output

After each cut print on a single line the area of the maximum available glass fragment in mm2.

Example
Input
4 3 4
H 2
V 2
V 3
V 1
Output
8
4
4
2
Input
7 6 5
H 4
V 3
V 5
H 2
V 1
Output
28
16
12
6
4
Note

Picture for the first sample test:

Picture for the second sample test:

思路就是将宽度和长度分开储存,分别求出两者的最大值,然后就可算出结果

一开始想着用两个数组存所有的分割点,最后用sort排序然后一个一个算出亮点间距离得出最大值,结果会超时

所以后来换用STL中的set来做

利用set保留值不重复且自动排序的特点,将割点用set保存

利用multiset可以保留重复值且也能自动排序的特点,将距离用multiset保存

这样在插入点的时候,set加入这个新的点,然后搜索这个新点的前后两个点,就可以得出被分割的那一段距离的大小X,然后在multiset中删除这段距离X(注意一次只能删除一段,如果用erase(X)的话会删除所有的段,只能erase(find(X)),具体操作可以去看看set用法的详解)

删除后将新生成的两段距离加入multiset,然后就可以输出答案了


代码

#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
set<long long>h1;
set<long long>w1;
set<long long>::iterator it;
multiset<long long>h2;
multiset<long long>w2;
multiset<long long>::iterator it2;
int main()
{
    ios::sync_with_stdio(false);
    int w,h,n;
    int sta,last;
    int pos;
    char order;
    int maxw,maxh;
    while(cin>>w>>h>>n)
    {
        w1.clear();
        w2.clear();
        h1.clear();
        h2.clear();
        w1.insert(0);
        h1.insert(0);
        w1.insert(w);
        h1.insert(h);
        w2.insert(w);
        h2.insert(h);
        for(int i=0;i<n;i++)
        {
            cin>>order>>pos;
            if(order=='H')
            {
                h1.insert(pos);
                sta=*(--h1.find(pos));
                last=*(++h1.find(pos));
                h2.erase(h2.find(last-sta));
                h2.insert(pos-sta);
                h2.insert(last-pos);
            }
            else
            {
                w1.insert(pos);
                sta=*(--w1.find(pos));
                last=*(++w1.find(pos));
                w2.erase(w2.find(last-sta));
                w2.insert(pos-sta);
                w2.insert(last-pos);
            }
            it2=w2.end();
            it2--;
            maxw=*it2;
            it2=h2.end();
            it2--;
            maxh=*it2;
            cout<<(*(--w2.end()))*(*(--h2.end()))<<endl;
        }
    }
    return 0;
}





Open3D 实现CSF布料模拟算法【2025最新版】 CSF布料模拟算法在open3d模块下的实现,博客长期更新,本文最近更新时间为:2025年1月16日。。 阅读详情

相关推荐

Nornir自动化简单介绍-网络设备信息收集

作为网工,学会通过执行脚本,可以自动化的完成日常一些设备相关配置或信息收集等工作,可以说是事半功倍。 Nornir就是这样一个自动化网络运维工具。按照官网上的说明: Nornir是用python编写的自动化框架,可与python一起使用。Nornir旨在通过提供一个纯Python框架来解决这些问题。 详细参考: Github GitHub - nornir-automation/nornir: Pluggable multi-threaded framework with inventory .

Gun&rose 7805

CodeForces - 527C----Glass Carving ---set和multiset

time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Leonid wants to become a glass carver (the person who creates beautiful artworks by cu...

sinat_41233888的博客 1211

SWIFT报文实战指南:从MT700到MT799的信用证操作全解析

本文深入解析了国际贸易中信用证操作的核心SWIFT报文流程,从开证的MT700到各类通知、修改及结算报文(如MT707、MT730、MT754、MT732/734等)。通过实战案例与关键字段拆解,指导外贸与银行从业者精准处理报文,规避风险,并探讨了利用自动化工具提升处理效率的方法,助力保障跨境交易顺畅。

weixin_29015801的博客 878

codeforces 527 C. Glass Carving

http://codeforces.com/problemset/problem/527/CC. Glass Carvingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLeonid wants to become a glass carve...

hao1001的博客 481

Unity UI适配实战:从Canvas Scaler到主流游戏适配方案解析

本文深入解析Unity UI适配的核心技术,重点介绍Canvas Scaler组件的关键参数如Reference Resolution和Screen Match Mode,并提供主流游戏适配方案实战分析。通过九宫格拉伸、动态调整等技巧,帮助开发者解决多设备适配难题,提升游戏UI在不同分辨率下的表现。

weixin_29001419的博客 971

宏基因组分析|完整分析流程梳理

今天先从最基础的全流程框架说起,无论是刚接触的萌新,还是想查漏补缺的同行,都能找到有用的信息。

weixin_70911870的博客 3164

CodeForces 527C:Glass Carving (set与multiset应用)

Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm  ×  h mm sheet of glass, a diamond glass cutter and lots of enthusiasm.

并非所有流浪者都迷失了自我 670

process插件_利用SPSS 插件MLmed检验多水平中介的调节模型

本文介绍一个SPSS插件,用于检验多水平中介的调节,及该方法与Mplus的比较。1 Mlmed 简介及安装Mlmed 简介: Mlmed 由Rockwood 2017年开发,基于SPSS插件计算Multilevel moderated mediation. 可以提供multilevel mediation Monte Carlo 置信区间比如(模拟20000次),以及多水平调节的...

weixin_39976081的博客 5772

codeforces#527 - C. Glass Carving (线段树)

codeforces527 - C. Glass Carving 链接: https://codeforces.com/problemset/problem/527/C 题解链接: https://blog.youkuaiyun.com/scau_cdx/article/details/89893591 https://www.cnblogs.com/shuaihui520/p/9835973.html 求最长连续0区间 Code: #include <algorithm> #include <ios

Gverzh的博客 287

多智能体强化学习MATD3算法完整复现与分析

多智能体强化学习MATD3算法复现与分析摘要 MATD3算法是多智能体深度强化学习领域的重要进展,通过改进MADDPG算法,引入双Q学习、延迟策略更新和目标策略平滑等技术,显著提升了算法稳定性。本文完整复现了MATD3算法,详细解析了其数学原理,包括部分可观测马尔可夫博弈模型和TD3核心思想。在实现层面,设计了集中式Critic和分布式Actor的神经网络架构,采用PyTorch框架构建了Actor-Critic网络模块,包含精心设计的权重初始化和训练流程。该算法有效解决了多智能体环境中的非平稳性、信用分配

max500600的博客 529

相位偏折PMD全栈技术拆解 | 四步相移解算+梯度积分形貌重建,助力镜面工件微米级缺陷高精度稳定检测

工业精密检测领域中,高反光镜面类工件长期存在检测瓶颈,涵盖汽车高亮车漆、半导体抛光晶圆、光学透镜、精密抛光模具、玻璃盖板等主流产品。传统2D机器视觉仅能识别表面明显污渍、大尺寸破损,完全无法捕捉微米级划痕、凹坑、橘皮、曲面微形变等微观缺陷;常规线激光3D、普通结构光3D检测设备,面对镜面材质会产生严重镜面反射杂光,激光条纹、结构光图案完全失真,必须喷涂显影粉辅助检测,不仅破坏工件表面完整性,还无法适配自动化量产产线,检测效率与良率极低。

getusushu的博客 543

Codeforces 527C Glass Carving(Set)

题意  一块w*h的玻璃  对其进行n次切割  每次切割都是垂直或者水平的  输出每次切割后最大单块玻璃的面积 用两个set存储每次切割的位置   就可以比较方便的把每次切割产生和消失的长宽存下来  每次切割后剩下的最大长宽的积就是答案了 #include using namespace std; const int N = 200005; typedef long long LL; set

Deng's site \# 1512

Jetson Orin 上拉取 GMSL 相机流并保存在 DMA 内存中

本文介绍了在NVIDIA Jetson Orin平台上实现GMSL相机DMA内存共享的低延迟采集方案。通过V4L2+NvBufSurface技术,将相机数据直接存入DMA缓冲区,避免传统流程中的CPU拷贝开销。文章详细说明了设备初始化、DMA缓冲区分配、V4L2绑定等关键步骤,并展示了调用示例。该方案支持零拷贝访问,适用于AI推理、硬件编码等场景,能显著提升车载视觉系统的实时性能,为多路GMSL相机接入和低延迟处理提供了高效解决方案。

J。 695

codeforces 527C Glass Carving

传送门:http://codeforces.com/problemset/problem/527/C 题目大意:你有一块玻璃,你可以横切(H)或者竖切(V),问你在每一步的时候这块玻璃上最小的那一块是什么。 解题思路: 你需要set以及mutiset来维护长度以及切的地方,然后暴力(手动滑稽)。 ac程序// // main.cpp // glass carving // // Cre

NightRaven的博客 735

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

CodeForces - 527C

Glass Carving:Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm  ×  h mm sheet of glass, a diamond

qq_35117637的博客 512

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

CodeForces 527C Glass Carving

C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leonid wants to become a glass carver (the

lizhaowei213的博客 626

lwip-2.0.3

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

题解 [CodeForces - 527C]Glass Carving

博客食用更佳哟

Always_yeye的博客 202

Codeforces Round #296 (Div. 2) - C. Glass Carving(STL)

题目: http://codeforces.com/contest/527/problem/C 题意: 求出在一个w, h (2 ≤ w, h ≤ 200 000)矩形中进行n(1 ≤ n ≤ 200 000)次横切或竖切操作之后得到的最大面积的矩阵. 思路: set大法. multiset H, W, nh, nv; nh :记录每一次横切操作; nw: 记录每一次竖切操作.

Halo 774

Codeforces 527C Glass Carving (set+multiset)

对于一个矩形,宽为w,高为h。现在对其进行一系列的切割。让你求出每次切割后的最大面积的矩形参考http://blog.youkuaiyun.com/u011580493/article/details/44457477 学习了下multiset。。 没想到STL那么好用 LL w,h,n; set<LL>st[2]; multiset<LL>mst[2]; LL solve(int sta,int val)

now_ing的博客 240

Codeforces Round #296 (Div. 2) C - Glass Carving(STL运用)

C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leonid wants to become a glass carver (the

kalilili的专栏 935

【题解】codeforces528A[AHSOFNU codeforces训练赛1 by hzwer]C.Glass Carving set

题目链接 Description Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm  ×  h mm sheet of glass, a diamond glass cutt...

翻过这座山,他们就会听到你的故事 305

Codeforces Round #296 (Div. 2) C. Glass Carving

C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leonid wants to become a glass carver (the

lljjccsskk的专栏 341

Codeforces 527C Glass Carving 线段树区间合并

传送门:  http://codeforces.com/contest/527/problem/C C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leoni

上决╇ф的ACM 1625

CF 527C Glass Carving 思路

用 0 1 序列表示每个点是否被切割,然后 最长的长就是长的最长连续0的数量+1 最长的宽就是宽的最长连续0的数量+1 于是用线段树维护最长连续0序列

Harrys_Snitch 787

Codeforces Round #296 (Div. 1) A. Glass Carving Set的妙用

A. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leonid wants to become a glass carver (the p...

weixin_33946020的博客 152

Codeforces 527C Glass Carving

Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm  ×  h mm sheet of glass, a diamond glass cutter and lots of

XDU_PYL的博客 864
上一篇: csuoj1023修路( )
下一篇: hdu2553八皇后问题(DFS)
T__TSZ
博客等级 码龄10年 2粉丝 70原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值