1153 Decode Registration Card of PAT (25 point(s))

电机控制个人学习路线及专业书籍资源分享 个人学习电机控制的学习路线,和相关专业书的电子文档分享 阅读详情

1153 Decode Registration Card of PAT (25 point(s))

A registration card number of PAT consists of 4 parts:

  • the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic;
  • the 2nd - 4th digits are the test site number, ranged from 101 to 999;
  • the 5th - 10th digits give the test date, in the form of yymmdd;
  • finally the 11th - 13th digits are the testee's number, ranged from 000 to 999.

Now given a set of registration card numbers and the scores of the card owners, you are supposed to output the various statistics according to the given queries.

Input Specification:

Each input file contains one test case. For each case, the first line gives two positive integers N (≤10​4​​) and M (≤100), the numbers of cards and the queries, respectively.

Then N lines follow, each gives a card number and the owner's score (integer in [0,100]), separated by a space.

After the info of testees, there are M lines, each gives a query in the format Type Term, where

  • Type being 1 means to output all the testees on a given level, in non-increasing order of their scores. The corresponding Term will be the letter which specifies the level;
  • Type being 2 means to output the total number of testees together with their total scores in a given site. The corresponding Term will then be the site number;
  • Type being 3 means to output the total number of testees of every site for a given test date. The corresponding Term will then be the date, given in the same format as in the registration card.

Output Specification:

For each query, first print in a line Case #: input, where # is the index of the query case, starting from 1; and input is a copy of the corresponding input query. Then output as requested:

  • for a type 1 query, the output format is the same as in input, that is, CardNumber Score. If there is a tie of the scores, output in increasing alphabetical order of their card numbers (uniqueness of the card numbers is guaranteed);
  • for a type 2 query, output in the format Nt Ns where Nt is the total number of testees and Ns is their total score;
  • for a type 3 query, output in the format Site Nt where Site is the site number and Nt is the total number of testees at Site. The output must be in non-increasing order of Nt's, or in increasing order of site numbers if there is a tie of Nt.

If the result of a query is empty, simply print NA.

Sample Input:

8 4
B123180908127 99
B102180908003 86
A112180318002 98
T107150310127 62
A107180908108 100
T123180908010 78
B112160918035 88
A107180908021 98
1 A
2 107
3 180908
2 999

Sample Output:

Case 1: 1 A
A107180908108 100
A107180908021 98
A112180318002 98
Case 2: 2 107
3 260
Case 3: 3 180908
107 2
123 2
102 1
Case 4: 2 999
NA

排序题。

1. 尽量使用printf和scanf,否则可能超时;

2. map<key,value>结构方便用来遍历计数,但是如果要基于key和value再排序,则需要遍历map,将它pair<key,value>存储成线性结构(如vector)再重载运算符输出。

map<string,int> mp;
vector<pair<string,int> > v = vector(mp.begin(),mp.end());
bool cmp(pair<string,int> p1,pair<string,int> p2){    }

3. 从字符串中读取信息可以用sscanf;

4. 对于命令1,可以在一开始就排好序,在遇到时顺序遍历即可。并且不会影响命令2和3。

Tips:

如果想要在Dev-Cpp里面使用C++11特性的函数,比如刷算法中常用的stoi、to_string、unordered_map、unordered_set、auto这些,需要在设置里面工具-编译选项-编译器-编译时加入“-std=c++11”
原文链接:https://blog.youkuaiyun.com/liuchuo/article/details/82669248

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<unordered_map>
using namespace std;
const int MAX = 1e4+7;
int N,M;
struct card{
	string cardNumber;
	string level;int site,date,number;int score;
};
bool cmp(card a,card b){
	if(a.score!=b.score) return a.score>b.score;
	return a.cardNumber<b.cardNumber; 
}
bool cmp2(pair<int,int> p1,pair<int,int> p2) {
    if(p1.second!=p2.second) return p1.second>p2.second;
    else return p1.first<p2.first;
}
card c[MAX];
int main(void){
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>c[i].cardNumber>>c[i].score;
		c[i].level = c[i].cardNumber.substr(0,1);
		c[i].site = stoi(c[i].cardNumber.substr(1,3));
		c[i].date = stoi(c[i].cardNumber.substr(4,6));
		c[i].number = stoi(c[i].cardNumber.substr(10,3));
	}
	int type;string s;
	sort(c,c+N,cmp); 
	for(int i=1;i<=M;i++){
		cin>>type>>s;
		cout<<"Case "<<i<<": "<<type<<" "<<s<<endl; 
		if(1==type){
			bool flag = false; 
			for(int i=0;i<N;i++){
				if(s==c[i].level){
					printf("%s %d\n",c[i].cardNumber.c_str(),c[i].score);
					flag = true;
				} 
			}
			if(!flag) puts("NA");
		}
		else if(2==type){
			int nt=0,ns=0;int key = stoi(s);
			for(int i=0;i<N;i++){
				if(c[i].site==key){
					nt++;
					ns+=c[i].score; 
				}
			}
			if(nt>0) cout<<nt<<" "<<ns<<endl;
			else puts("NA");
		}
		else if(3==type){
			unordered_map<int,int> mp;int key = stoi(s);
			for(int i=0;i<N;i++){
				if(key== c[i].date){
					mp[c[i].site]++;
				}
			} 
			if(mp.size()==0) puts("NA");
			else{
				vector<pair<int,int> >vec(mp.begin(),mp.end());
				sort(vec.begin(),vec.end(),cmp2);
				for(int i=0;i<vec.size();i++){
					printf("%03d %d\n",vec[i].first,vec[i].second);
				}
			}
		} 
	}
	return 0;
}

 

C# WPS操作PPT,全屏,缩率图,备注,跳转播放 本文介绍了一个使用C#开发的PPT操作工具,主要功能包括检测当前打开的PPT文件、获取选中PPT路径、指定播放PPT、获取PPT页面序号和缩略图、提取备注内容等。文章展示了操作界面效果图,并重点解决了用户手动退出PPT后重新获取路径时报错的问题。核心代码实现了通过WPS API进行PPT文件的打开、全屏播放、页面跳转、获取当前页位置等功能,同时支持生成PPT缩略图预览和备注信息提取。当用户未通过工具按钮打开PPT时,程序会自动初始化PPT信息确保功能正常使用。 阅读详情

相关推荐

FPGA开发中Quartus与Modelsim联合仿真配置与调试全攻略

在数字电路设计与FPGA开发中,仿真验证是确保逻辑功能正确性和时序性能达标的核心环节。其基本原理是通过软件模拟硬件电路的行为,在设计转化为实际硬件前发现潜在缺陷。这项技术的核心价值在于大幅降低开发风险与成本,提升设计可靠性,广泛应用于通信、嵌入式系统、芯片验证等领域。对于使用Intel FPGA平台的开发者,Quartus Prime作为官方综合布局布线工具,其内置仿真器在应对复杂设计、深度调试和自动化测试时存在局限。此时,引入专业仿真工具Modelsim进行联合仿真成为提升验证效率的关键实践。通过搭建自动

weixin_33736048的博客 451

「1153」Decode Registration Card of PAT

A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basic; the 2nd - 4th digits are the test...

weixin_52435933的博客 361

电子取证之服务器取证思路

服务器取证是一个技术性很强的领域,涉及到多个环节,包括网站重构、网站代码分析、容器分析等。数据库密码的获取通常通过查看配置文件、日志文件、备份等途径,同时可以通过一些绕过技术如禁用身份验证来获取权限。对于不同的数据库,需要根据其特性采取相应的应对方法和命令。

2401_84830066的博客 2490

PAT-A 1153 Decode Registration Card of PAT

A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site nu...

JoJo's blog 487

跟着团子学SAP PS:项目计划成本与项目预算设计思路

​在做SAP PS模块概览培训的时候,很多时候都会用到下面的一页PPT片子讲到项目计划成本与预算的关系,但真正这幅片子想表达的具体内容甚至大部分PS顾问也是无法阐明清楚的。 而SAP PS的设计其实是在丰富的项目管理学的基础上而开展的,所以今天从业务上结合SAP中的功能点讲一下项目成本计划及预算的逻辑。 在项目管理的十大知识领域中,项目成本管理主要是包括为使项目在批准的预算内完成而对成本进行规划...

Lucas1211的博客 3万+

【ros】ROS1的安装和相关使用方法

主要学习ros相关内容

Greary的博客 2379

爆刷PAT(甲级)——之【1153】 Decode Registration Card of PAT (25 分)——模拟细节题(如何解决超时问题!)

此题是去年12月份甲级PAT没有拿到全分的题目。当时最后两个点没有过,所以最可能拿满分的一次机会白白流失掉了。 当初最后两个点是因为超时,一时半会没想到如何去优化。回来以后也没有花时间再去解决这个TLE问题。 昨天晚上突然想到这题,抽时间写了一下,花了2个小时还是最后两个点没有过,百思不得其解。 今天解决了这个问题,觉得有毒。 网上各大博客都没有着重点出如何解决这个TLE(超时)问题,也很...

Hide_in_Code 996

NVIDIA DRIVE SDK深度解析(一)——核心组件与安全架构设计

本文深度解析NVIDIA DRIVE SDK的核心组件与安全架构设计,涵盖DriveOS、加速库和应用框架三层架构,以及虚拟化与安全隔离机制。重点探讨了安全岛设计、媒体处理流水线和功能安全监控体系,为开发者提供自动驾驶系统开发的实战建议和性能优化技巧。

weixin_28704565的博客 567

1153 Decode Registration Card of PAT (PAT甲级)

这道题因为运行超时,卡了很久。

linh2006的博客 186

超螺旋滑模控制(STA)

超螺旋滑模控制又称超扭滑模控制,可以说是二阶系统中最好用的滑模控制方法。

Lyajpunov的博客 1万+

正确使用 SGLang 和 vLLM 中为 Qwen3 开启工具调用能力的完整指南

本文介绍了在vLLM和SGLang框架中部署Qwen3大模型并启用工具调用功能的方法。主要内容包括:vLLM中需配置--tool-call-parser hermes和--enable-auto-tool-choice参数,SGLang中使用--tool-call-parser qwen25参数;提供了完整的部署命令示例和测试工具调用的curl请求模板;对比了两个框架的关键参数差异;总结了常见问题解决方案和性能优化建议。正确配置后,Qwen3能够充分发挥其外部工具调用能力,为AI应用开发提供支持。

Ven%的博客 4453

PAT 1153 Decode Registration Card of PAT (25 分)- 甲级

A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic;the 2nd – 4th digits are the test site numb...

柳婼 の blog 8455

华为OD机试 - 末世分配资源包 - 二分查找 + 贪心(Python/JS/C/C++ 新系统 100分)

本专栏收录于《华为OD机试真题(Python/JS/C/C++)》。刷的越多,抽中的概率越大,私信哪吒,备注华为OD,加入华为OD刷题交流群,每一题都有详细的答题思路、详细的代码注释、3个测试用例、为什么这道题采用XX算法、XX算法的适用场景,发现新题目,随时更新。末世时代,政府为各地方配资源,现有资源分配表 nums[n],要求按如下规则分配给 k 个营地:在最优平均分配情况下,得到最大团队所获得的资源数4,3,6,9,7 216最佳划分之一:[4,3,6] -> 13 [9,7] -> 16最大

学Java,找哪吒 224

1153 Decode Registration Card of PAT (25 point(s))

A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and Bfor basic; the 2nd - 4th digits are the test site num...

zclimou的博客 302

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

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

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

【PAT】A1153 Decode Registration Card of PAT (25 point(s))

文章目录A1153 Decode Registration Card of PAT (25 point(s))Input Specification:Output Specification:Sample Input:Sample Output: A1153 Decode Registration Card of PAT (25 point(s)) registration card number...

Duke 231

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

1153 Decode Registration Card of PAT (25 point(s))

结构体排序 + map映射

Bonstoppo 231

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

1153 Decode Registration Card of PAT (25point(s)) - C语言 PAT 甲级

* 排好序按要求输出

有三只土豆 691

PAT A1153 Decode Registration Card of PAT (25point(s))

A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site num...

qq_42347617的博客 188

PAT_甲级_1153 Decode Registration Card of PAT (25point(s)) (C++)【模拟/数据结构设计/排序/】

1,题目描述 Sample Input: 8 4 B123180908127 99 B102180908003 86 A112180318002 98 T107150310127 62 A107180908108 100 T123180908010 78 B112160918035 88 A107180908021 98 1 A 2 107 3 180908 2 999 S...

&再见萤火虫&的博客 294

PAT-A1153/B1095 Decode Registration Card of PAT/解码PAT准考证 题目内容及题解

A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site nu...

BourbonWhiskey 的博客 1002

1153 Decode Registration Card of PAT (25 分)

\quad熟练运用map和sort就很容易。需注意第四个测试点用map会超时,全部用unordered_map就好。 #include <bits/stdc++.h> using namespace std; const int maxn = 1e4+10; unordered_map<char, vector<pair<string, int> > ...

qq_40438165的博客 2019

PAT A1153 Decode Registration Card of PAT (25分)

PAT甲级1153记录原题大体翻译大体思路第一次编写提交结果第二次编写提交结果 原题 A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; ...

kyln1039的博客 550

PAT 甲级 1153  Decode Registration Card of PAT

1153Decode Registration Card of PAT(25 point(s)) A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBf...

漫浸天空的雨色的备忘录~ 1018

1153 Decode Registration Card of PAT (25)

TAByymmdd。

2401_88085478的博客 1011

1153 Decode Registration Card of PAT

A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site numb...

L_Aster的专栏 556

18冬第二题 PAT甲级 1153 Decode Registration Card of PAT (25分) 鸡贼的题

题目 A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basic; the 2nd - 4th digits are the test sit...

qiiingc的解题记录 3万+
上一篇: 1144 The Missing Number (20 point(s))
下一篇: 1154 Vertex Coloring (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值