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 andB
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 (≤) and M (≤), the numbers of cards and the queries, respectively.
Then N lines follow, each gives a card number and the owner's score (integer in [), 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 correspondingTerm
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 correspondingTerm
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 correspondingTerm
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
whereNt
is the total number of testees andNs
is their total score; - for a type 3 query, output in the format
Site Nt
whereSite
is the site number andNt
is the total number of testees atSite
. The output must be in non-increasing order ofNt
's, or in increasing order of site numbers if there is a tie ofNt
.
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
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream> using namespace std; int fuck[1005];
struct Student
{
int score;
string id;
};
struct part
{
int count=1;
int id;
};
vector<Student> seq;
bool cmp(Student a,Student b)
{
if(a.score!=b.score) return a.score>b.score;
else return a.id<b.id; }
bool cmp1(part a,part b)
{
if(a.count!=b.count) return a.count>b.count;
else return a.id<b.id;
}
int main()
{
int seqnum;
int cxnum;
scanf("%d %d",&seqnum,&cxnum);
for(int i=0;i<seqnum;i++)
{
Student temp;
cin>>temp.id;
cin>>temp.score;
seq.push_back(temp);
}
for(int i=1;i<=cxnum;i++)
{
vector<Student> result;
int mode;
string cxid;
scanf("%d",&mode);
cin>>cxid;
if(mode==2)
{
int sum=0;
int count=0;
for(int j=0;j<seq.size();j++)
{
string ttemp;
for(int t=1;t<4;t++)
{
ttemp.push_back(seq[j].id[t]);
}
if(ttemp==cxid)
{
sum+=seq[j].score;
count++;
} }
printf("Case %d: %d ",i,mode);
cout<<cxid<<endl;
if(count!=0) printf("%d %d",count,sum);
else printf("NA");
}
if(mode==1)
{
vector<Student> result;
for(int j=0;j<seq.size();j++)
{
if(seq[j].id[0]==cxid[0])
{
result.push_back(seq[j]);
}
}
sort(result.begin(),result.end(),cmp);
printf("Case %d: %d ",i,mode);
cout<<cxid<<endl;
if(result.size()!=0)
{
for(int j=0;j<result.size();j++)
{
cout<<result[j].id;
printf(" %d",result[j].score);
if(j!=result.size()-1) printf("\n");
}
}
else
{
printf("NA");
}
}
if(mode==3)
{
fill(fuck,fuck+1005,0);
bool flag=false;
for(int j=0;j<seq.size();j++)
{ int xx=0;
int tt;
for(tt=4;tt<10;tt++)
{
if(cxid[xx++]!=seq[j].id[tt]) break;
}
if(tt==10)
{
flag=true;
char a[10];
int acount=0;
int fucku;
for(int mm=1;mm<4;mm++)
{
a[acount++]=seq[j].id[mm];
}
sscanf(a,"%d",&fucku); fuck[fucku]++;
}
}
printf("Case %d: %d ",i,mode);
cout<<cxid<<endl;
if(flag)
{
vector<part> aseq;
for(int y=0;y<1005;y++)
{
if(fuck[y]!=0)
{
part tpart;
tpart.count=fuck[y];
tpart.id=y;
aseq.push_back(tpart);
}
}
sort(aseq.begin(),aseq.end(),cmp1);
for(int t=0;t<aseq.size();t++)
{
printf("%d %d",aseq[t].id,aseq[t].count);
if(t!=aseq.size()-1) printf("\n");
} }
else
{
printf("NA");
} }
if(i!=cxnum) printf("\n");
}
}
1153 Decode Registration Card of PAT的更多相关文章
- PAT甲 1095 解码PAT准考证/1153 Decode Registration Card of PAT(优化技巧)
1095 解码PAT准考证/1153 Decode Registration Card of PAT(25 分) PAT 准考证号由 4 部分组成: 第 1 位是级别,即 T 代表顶级:A 代表甲级: ...
- 1153 Decode Registration Card of PAT (25 分)
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...
- PAT Advanced 1153 Decode Registration Card of PAT (25 分)
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...
- 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, nam ...
- PAT_A1153#Decode Registration Card of PAT
Source: PAT A1153 Decode Registration Card of PAT (25 分) Description: A registration card number of ...
- PAT-1153(Decode Registration Card of PAT)+unordered_map的使用+vector的使用+sort条件排序的使用
Decode Registration Card of PAT PAT-1153 这里需要注意题目的规模,并不需要一开始就存储好所有的满足题意的信息 这里必须使用unordered_map否则会超时 ...
- PAT A1153 Decode Registration Card of PAT (25 分)——多种情况排序
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...
- PAT(甲级)2018年冬季考试
1152 Google Recruitment 思路:判断素数 #include<bits/stdc++.h> using namespace std; const int maxn = ...
- PAT甲级 排序题_C++题解
排序题 PAT (Advanced Level) Practice 排序题 目录 <算法笔记> 6.9.6 sort()用法 <算法笔记> 4.1 排序题步骤 1012 The ...
随机推荐
- 机器学习算法-PCA降维技术
机器学习算法-PCA降维 一.引言 在实际的数据分析问题中我们遇到的问题通常有较高维数的特征,在进行实际的数据分析的时候,我们并不会将所有的特征都用于算法的训练,而是挑选出我们认为可能对目标有影响的特 ...
- LeetCode141-环形链表检测
题目 给定一个链表,判断链表中是否有环. 如果链表中有某个节点,可以通过连续跟踪 next 指针再次到达,则链表中存在环. 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置 ...
- selenium爬虫 | 爬取疫情实时动态(二)
'''@author:Billie更新说明:1-28 17:00 项目开始着手,spider方法抓取到第一条疫情数据,save_data_csv方法将疫情数据保存至csv文件1-29 13:12 目标 ...
- 修改hosts文件后不生效,该怎么办
对于web开发来说,经常需要修改hosts文件,用来将域名与ip对应匹配.但是有时候发现hosts文件明明已经改了,但就是不生效,页面还会跳到某个丧心病狂的私人小站.hosts文件不生效有很多种原因, ...
- MyISAM与InnoDB两者之间区别与选择(转)
Mysql在V5.1之前默认存储引擎是MyISAM:在此之后默认存储引擎是InnoDB MyISAM:默认表类型,它是基于传统的ISAM类型,ISAM是Indexed Sequential Acces ...
- 基于kubernetes实现coredns的及验证
CoreDNS: k8s内部的DNS ,用于对pod对service做记录的,好让其他的pod做访问 这里不用做过多的阐述 官方kube-dns现在已经没有在维护了,从Kubernetes 1.11 ...
- 镍氢可充电电池2.4V转3.3V,2V转3.3V稳压供电输出电路图
PW5100可以实现2.4V转3.3V,2V转3.3V的稳压电源电路,输出电流500MA.静态电流10uA,SOT23-5封装.输出纹波低,轻载性能高(轻载电感推荐6.8UH-10UH). PW510 ...
- RecyclerView 源码分析(二) —— 缓存机制
在前一篇文章 RecyclerView 源码分析(一) -- 绘制流程解析 介绍了 RecyclerView 的绘制流程,RecyclerView 通过将绘制流程从 View 中抽取出来,放到 Lay ...
- Android 开发学习进程0.27 kotlin使用 和viewbinding的使用
kotlin-android-extensions 插件被废弃 笔者曾经尝试写过一部分的kotlin代码 主要是项目中一些代码是kotlin完成的,其中我认为 kotlin的kotlin-androi ...
- 开心!再也不用担心 IntelliJ IDEA 试用过期了
背景 前段时间 Review 团队小伙伴代码,发现当他把鼠标挪到一个方法上时,就自动显示了该方法的所有注释信息,像下图这样,他和我用的 IDE 都是 IntelliJ IDEA. 而我还按古老的方式, ...