1095 Cars on Campus (30 point(s))

Dynamics CRM证书更换   Dynamics CRM产品一般有两种认证方式。第一种是基于声明的内部访问也就是无证书单纯用账号密码验证。第二种就是联合身份认证,需要安装网站证书。   对于联合身份认证的情况因为需要安装证书,而且证书是有一个一年的有效期,所以运维人员每年都需要进行证书更换的操作。以下就是更换证书的方法及过程。 证书根据申请方式一般也分两种,第一种是自建证书,这种证书是没有机构认证的所以安装上之后网站因为没... 阅读详情

1095 Cars on Campus (30 point(s))

Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you are supposed to tell, at any specific time point, the number of cars parking on campus, and at the end of the day find the cars that have parked for the longest time period.

Input Specification:

Each input file contains one test case. Each case starts with two positive integers N (≤10​4​​), the number of records, and K (≤8×10​4​​) the number of queries. Then N lines follow, each gives a record in the format:

plate_number hh:mm:ss status

where plate_number is a string of 7 English capital letters or 1-digit numbers; hh:mm:ss represents the time point in a day by hour:minute:second, with the earliest time being 00:00:00 and the latest 23:59:59; and status is either in or out.

Note that all times will be within a single day. Each in record is paired with the chronologically next record for the same car provided it is an out record. Any in records that are not paired with an out record are ignored, as are out records not paired with an in record. It is guaranteed that at least one car is well paired in the input, and no car is both in and out at the same moment. Times are recorded using a 24-hour clock.

Then K lines of queries follow, each gives a time point in the format hh:mm:ss. Note: the queries are given in ascending order of the times.

Output Specification:

For each query, output in a line the total number of cars parking on campus. The last line of output is supposed to give the plate number of the car that has parked for the longest time period, and the corresponding time length. If such a car is not unique, then output all of their plate numbers in a line in alphabetical order, separated by a space.

Sample Input:

16 7
JH007BD 18:00:01 in
ZD00001 11:30:08 out
DB8888A 13:00:00 out
ZA3Q625 23:59:50 out
ZA133CH 10:23:00 in
ZD00001 04:09:59 in
JH007BD 05:09:59 in
ZA3Q625 11:42:01 out
JH007BD 05:10:33 in
ZA3Q625 06:30:50 in
JH007BD 12:23:42 out
ZA3Q625 23:55:00 in
JH007BD 12:24:23 out
ZA133CH 17:11:22 out
JH007BD 18:07:01 out
DB8888A 06:30:50 in
05:10:00
06:30:50
11:00:00
12:23:42
14:00:00
18:00:00
23:59:00

Sample Output:

1
4
5
2
1
0
1
JH007BD ZD00001 07:20:09

 复杂模拟。目前为止唯一一道没有自己做出来的模拟。

大概思路:

1. 按照车牌号索引,存储每个车牌号对应的出入记录,然后对各自的记录进行排序。

2. 按照题设要求(in和out对应等),将有效的记录存储在vector<record> valid(注意理解题意,两个合法的记录之间必然是相邻的)。

3. 对于每一个车牌号的记录,记录它们的停车时间和,并注意更新。

4. 对于每一个查询(注意时间递增),根据valid来计算当前车辆数。

注意点:

1. 题意的理解;

2. STL的使用:vector/map/set

#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
struct record{
	int time;string status;
	record(int t,string s):time(t),status(s){}
	bool operator < (const record &other) const{
		return time<other.time;
	}
};
map<string,vector<record> >mp;
vector<record> valid;
int main(void){
	int N,K;cin>>N>>K;
	string p,s;int hh,mm,ss;
	while(N--){
		cin>>p;
		scanf("%d:%d:%d",&hh,&mm,&ss);
		cin>>s;
		mp[p].push_back(record(3600*hh+60*mm+ss,s));
	}
	set<string> maxPlate;
	int maxTime = 0;
	map<string,vector<record> >::iterator i;
	for(i=mp.begin();i!=mp.end();i++){
		sort((i->second).begin(),(i->second.end()));
		int total=0;
		for(int j=0;j<(i->second).size()-1;j++){
			if((i->second)[j].status=="in"&&(i->second)[j+1].status=="out"){
				valid.push_back((i->second)[j]);
				valid.push_back((i->second)[j+1]);
				total+=((i->second)[j+1].time-(i->second)[j].time); 
			}
		}
		if(total>maxTime){
			maxPlate.clear();
			maxPlate.insert(i->first);
			maxTime = total;
		}else if(total==maxTime){
			maxPlate.insert(i->first);
		}
	}
	sort(valid.begin(),valid.end());
	int park = 0;int idx = 0;
	while(K--){
		scanf("%d:%d:%d",&hh,&mm,&ss);
		int t = 3600*hh+60*mm+ss;
		while(idx<valid.size()&&valid[idx].time<=t){
			if(valid[idx].status=="in") park++;
			else park--;
			idx++;
		}
		cout<<park<<endl;
	}
	set<string>::iterator it;
	for(it=maxPlate.begin();it!=maxPlate.end();it++){
		cout<<*it<<" "; 
	} 
	printf("%02d:%02d:%02d",maxTime/3600,maxTime%3600/60,maxTime%60);
	return 0;
} 

 

SIWAVE仿真PCB操作说明 使用SIWAVE进行PCB仿真提取S参数的操作 阅读详情

相关推荐

基于大疆TSDK与Pix4D的热红外数据工程化处理:从RJPG到温度正射影像的完整工作流

本文详细介绍了基于大疆TSDK与Pix4D的热红外数据工程化处理完整工作流。通过Python脚本自动化解析RJPG格式的热红外图像,提取并转换其中的原始辐射数据为包含真实温度信息的TIFF文件,再结合Pix4Dmapper进行批量拼接,最终生成可直接用于GIS分析的温度正射影像图。该流程解决了手动处理效率低下、参数校准复杂等难题,实现了从原始数据到定量分析成果的高效、准确、可重复生产。

weixin_29161785的博客 377

【PAT甲级 - C++题解】1095 Cars on Campus

📣专栏定位:为想考甲级PAT的小伙伴整理常考算法题解,祝大家都能取得满分!

Newin2020的博客 1172

K8s认证文件丢失的应急处理与恢复策略

本文详细介绍了Kubernetes(K8s)认证文件丢失时的应急处理与恢复策略。从快速诊断问题范围到不同场景的临时解决方案,再到深度恢复方案(无损重建、部分重置、完全重建),提供了全面的操作指南。同时强调了生产环境中的防丢失设计、高可用集群的特殊处理以及日常运维建议,帮助运维人员有效应对认证文件丢失的紧急情况。

weixin_33743248的博客 327

1095. Cars on Campus (30)-PAT甲级真题

给出n条车辆出入的记录,按时间顺序一一匹配。然后给出k个时间点,找到这k个时间点对应校园内车辆的数量。最后输出停留时间最长的车名。这里理解了就知道可以按时间排好序后,找到一前一后相同name的进出记录。

hzj913313180的博客 196

如何设计ADAS系统功能状态机(一)

状态机模块在自动驾驶系统中扮演着关键的角色,它负责管理和控制各个功能的状态转换和行为执行。今天我们来聊聊如何设计自动驾驶系统的状态机。

supass2018的博客 1617

360可视门铃双摄版数据恢复实战:BIN文件解析与视频重组

本文详细解析了360可视门铃双摄版BIN文件的数据恢复过程,包括文件结构分析、双摄像头数据存储机制及视频重组技术。通过Python开发环境和FFmpeg工具链,成功实现了H.265视频流的解析与重组,为智能家居设备数据恢复提供了实用解决方案。

weixin_29196891的博客 913

PAT甲级真题 1095 Cars on Campus (30分) C++实现(结构体排序,匹配停车场in、out信息)

题目 Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you are supposed to tell, at any specific time point, the

zhang35的博客 481

硬件工程师进阶之路:从电路基础到PCB设计实战核心技能

硬件电路设计是一项融合电路理论、器件特性与工程实践的复合型技术。一块稳定可靠的电路板,不仅需要正确的原理图,更依赖于合理的叠层规划、元器件布局与布线策略。在高速数字电路日益普及的今天,信号完整性、电源完整性与电磁兼容性设计已成为决定产品成败的关键因素,工程师需要深入理解阻抗匹配、回流路径、去耦电容布置等技术原理,并将理论灵活应用于通信设备、消费电子、工业控制等各类产品研发场景。PCB设计正是连接电原理图与可量产产品之间的核心枢纽,也是硬件工程师能力进阶过程中的分水岭技能。掌握从基础电路分析到高速PCB设计,

weixin_29183637的博客 266

PAT甲级 1095 Cars on Campus (30分) map/C++

1095 Cars on Campus (30分) 题目大意:给定车的进出时间,要求去掉不合法的数据(只有进没有出,只有出没有进)。问query中的时间点校园内有多少辆车,并且输出在校园中停留时间最长的车序列。 这道题真的很需要耐心和细心,考察stl的使用 捋一捋思路: 去掉不合法的数据,也就是in和out要配对:先对时间进行排序,排完以后必定是一进一出配对的出现,如果不成对出现则舍弃; 计算停留时间最长的车:在去掉不合法数据的同时,计算其停留时间,使用map来存放,以便下一次直接找到并增加停留时长; q

qq_43955154的博客 322

“快速掌握Vivado FPGA开发流程“——详解Vivado开发流程及实例

快速掌握Vivado FPGA开发流程”——详解Vivado开发流程及实例FPGA技术在现代电子领域中应用越来越广泛,而Vivado作为业界最流行的FPGA设计工具之一,也受到越来越多人的关注和使用。那么如何快速掌握Vivado FPGA开发流程呢?本文将详细介绍Vivado开发流程,并通过实例来加深您的理解。首先,我们需要了解Vivado开发流程的主要步骤:创建工程、设计电路、约束电路、生成比特流。接下来,让我们一步步了解这些步骤。

2301_78484069的博客 733

手把手教你学Simulink——基于新型电力电子拓扑与宽禁带器件的电网系统场景实例:GaN HEMT器件在高频逆变器中的开关特性建模

本文介绍了基于Simulink和Simscape Electrical的GaN HEMT高频逆变器建模方法。通过构建半桥拓扑电路,详细说明了GaN器件参数设置(以EPC2045为例)、专用驱动电路设计(含负压关断和米勒钳位)以及开关瞬态过程仿真(配置1ns步长捕捉MHz级特性)。重点分析了开关损耗计算和寄生导通风险,并对比了GaN与Si MOSFET的性能差异。案例展示了如何优化驱动参数和PCB布局,验证了GaN器件在1MHz高频应用中的优势(开关损耗仅5μJ)。最后总结了GaN在数据中心电源、无线充电等领

MHD0815的博客 405

1095. Cars on Campus (30)

1.事件模拟 2.首先读取所有的汽车记录数据,筛选出合理的进入和离开时间,放到一个vector里面,对这个vector进行排序处理,进入时间早的放在前面 3.对每一秒进行模拟,已经进入的车辆用一个小根堆进行存储维护,离开时间早的,排在堆顶 3.取下一次进入校园车辆的时间,下一次离开校园车辆的时间,下一次查询的时间,取三者的最小值,直接跳那个时间点,进行处理,优化时间复杂度 4.一开始第4个

Siukwan Program 654

YOLO26-Quantized:面向国产AI芯片的全栈量化方案,适配昇腾310P与寒武纪MLU270

在算力国产化替代的行业趋势下,昇腾310P、寒武纪MLU270已成为工业边缘视觉、智能检测场景的主流国产AI芯片选型。针对原生YOLO26模型在国产芯片上推理效率低、算子兼容性差、量化精度塌陷三大核心痛点,本文提出YOLO26-Quantized全栈量化方案,覆盖训练感知量化(QAT)、离线静态量化(PTQ)、模型编译优化、芯片专属部署全流程。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 764

1095 Cars on Campus (30 point(s))

题解 与1016题类似。。。 注:不能用stime当变量。。。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;vector&gt; #include&lt;algorithm&gt; #include&lt;map&gt; #include&lt;cstring&gt; #include&lt;string&gt

徐伯莱 293

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

PTA甲级 1095 Cars on Campus (30point(s))

首先,先贴柳神的博客 https://www.liuchuo.net/ 这是地址 想要刷好PTA,强烈推荐柳神的博客,和算法笔记 这一篇博客大部分都是借鉴(抄袭)的算法笔记 题目原文 Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and th...

Huangpengyu123的博客 318

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

1095 Cars on Campus (30point(s))

1095 Cars on Campus (30point(s)) Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you are supposed to tell, at

佳迪斯的博客 161

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

【PAT】A1095 Cars on Campus (30point(s))

文章目录A1095 Cars on Campus (30point(s))Input Specification:Output Specification:Sample Input:Sample Output:CodeAnalysis Author: CHEN, Yue Organization: 浙江大学 Time Limit: 300 ms Memory Limit: 64 MB Code S...

Duke 220

1095 Cars on Campus (30point(s)) - C语言 PAT 甲级

按照车牌号字典序从小到大,时间从小到大对所有车进行排序 * 遍历且仅记录满足配对要求的每对记录 * 遍历过程中记录每辆车停留的时间 * 同一辆车会有多次满足配对要求的记录,所以对于停留时间要判断累加 * 并记录最大值和车牌号 * 利用满足配对要求的记录,按秒记录每个时间点在校园内的车辆数目,查询时,直接返回对应时间的数目即可

有三只土豆 214

PAT----A1095 Cars on Campus (30point(s))

A1095 Cars on Campus (30point(s)) 排序 题意 记录按照时间配对,排序题,略为繁琐。 一定要注意题目要求在一对合法的in和out之间不能有该车牌号的in和out记录,我就被这个坑了。 思路 时间处理:换算为秒; 使用map实现合法记录配对。 Sample Input: 16 7 JH007BD 18:00:01 in ZD00001 11:30:08 out DB8...

qq_43578870的博客 135

PAT_甲级_1095 Cars on Campus (30point(s)) (C++)【模拟/map+vector+set+struct】

目录 1,题目描述 题目大意 注意 2,思路 数据结构 算法 3,AC代码 4,解题过程 第一搏 1,题目描述 the plate numbers of the cars crossing the gate:过门车辆的车牌号; chronologically:按时间顺序; Sample Input: 16 7 JH007BD 18:00:01 in ZD00001 ...

&再见萤火虫&的博客 223

1095 Cars on Campus (30 point(s))(C++)

Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you a...

qq_41562704的博客 260

PAT A1095

方法:排序+map的使用。 注意点:1,无效数据的处理;2,最大值对应的车牌号按字母序输出;3,处理查询的时间复杂度应低于N^2,否则会超时。 #include #include #include #include #include #include using namespace std; const int maxn=100010; struct record{ int ti

weixin_37565706的博客 359

1095 Cars on Campus (30 分)

1095Cars on Campus(30分) Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the ...

chen_zan_yu_的博客 145

A1095. Cars on Campus

Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, ...

W87234331的博客 178

1095 Cars on Campus (30)(30 分)

Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, y...

weixin_30443895的博客 154

Cars On Campus

PTA FDS PROJECT 3

菜鸡园 568
上一篇: 1051 Pop Sequence (25 point(s))
下一篇: 1070 Mooncake (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值