A registration card number of PAT consists of 4 parts:
T
for the top level, A
for advance and B
for basic;yymmdd
;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.
Each input file contains one test case. For each case, the first line gives two positive integers N (≤104) 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.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:
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);Nt Ns
where Nt
is the total number of testees and Ns
is their total score;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
.
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
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
本文参考了大佬:https://blog.csdn.net/Hickey_Chen/article/details/84933814
题目大意:N个学生考号,M个问题。题目读懂了也不难,此处就不翻译了,总结一下我遇到的问题吧:开始我把考号中的每一项都写进结构体里,以为处理起来方便点,超时了,之后放一起多了4分。之后便是最坑的cin,cout所需要的时间远超过printf和scanf。改了后19。最后一点就是我将unordered_map定义在了全局变量。。。。。写在里边后满分了。最后感谢大佬代码参考。代码如下:
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn=1e4+10;
struct card{
string id;
int score;
}St[maxn],co[maxn];
struct cr{
int cnt;
string tnum;
}Cr[maxn];
bool cmp(card a, card b)
{
return (a.score==b.score?a.idb.score);
}
bool cmmp(cr a, cr b)
{
return (a.cnt==b.cnt?a.tnumb.cnt);
}
int main()
{
// freopen("1153.txt","r",stdin);
int n,m,sc,type;
string str,s;
cin>>n>>m;
for(int i=0;i>str>>sc;
St[i].id=str;
St[i].score=sc;
}
for(int i=1;i<=m;i++){
cin>>type>>s;
int found=0;
switch(type){
case 1:
{
int k=0;
for(int j=0;j mp;
for(int j=0;jfirst;
int value=it->second;
Cr[z].tnum=key; //将结果存放到新的结构体中进行处理
Cr[z].cnt=value;
z++;
}
sort(Cr,Cr+z,cmmp);
for(int p=0;p