• 1141 PAT Ranking of Institutions


    After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.

    Input Specification:

    Each input file contains one test case. For each case, the first line gives a positive integer N (≤105), which is the number of testees. Then N lines follow, each gives the information of a testee in the following format:

    ID Score School
    

    where ID is a string of 6 characters with the first one representing the test level: B stands for the basic level, A the advanced level and T the top level; Score is an integer in [0, 100]; and School is the institution code which is a string of no more than 6 English letters (case insensitive). Note: it is guaranteed that ID is unique for each testee.

    Output Specification:

    For each case, first print in a line the total number of institutions. Then output the ranklist of institutions in nondecreasing order of their ranks in the following format:

    Rank School TWS Ns
    

    where Rank is the rank (start from 1) of the institution; School is the institution code (all in lower case); ; TWS is the total weighted score which is defined to be the integer part of ScoreB/1.5 + ScoreA + ScoreT*1.5, where ScoreX is the total score of the testees belong to this institution on level X; and Ns is the total number of testees who belong to this institution.

    The institutions are ranked according to their TWS. If there is a tie, the institutions are supposed to have the same rank, and they shall be printed in ascending order of Ns. If there is still a tie, they shall be printed in alphabetical order of their codes.

    Sample Input:

    1. 10
    2. A57908 85 Au
    3. B57908 54 LanX
    4. A37487 60 au
    5. T28374 67 CMU
    6. T32486 24 hypu
    7. A66734 92 cmu
    8. B76378 71 AU
    9. A47780 45 lanx
    10. A72809 100 pku
    11. A03274 45 hypu

    Sample Output:

    1. 5
    2. 1 cmu 192 2
    3. 1 au 192 3
    4. 3 pku 100 1
    5. 4 hypu 81 2
    6. 4 lanx 81 2
    1. #include
    2. #include
    3. #include
    4. #include
    5. using namespace std;
    6. struct Ins {
    7. string id;
    8. int sb, sa, st, score, num;
    9. } a[100010];
    10. mapint>cnt;
    11. mapm;
    12. int n, t;
    13. string x, y;
    14. int s;
    15. bool cmp(Ins i1, Ins i2) {
    16. return i1.score == i2.score ? (i1.num == i2.num ? i1.id < i2.id : i1.num < i2.num) : i1.score > i2.score;
    17. }
    18. int main() {
    19. cin >> n;
    20. for (int i = 0; i < n; i++) {
    21. cin >> x >> s >> y;
    22. for (int j = 0; j < y.size(); j++) {
    23. if (y[j] >= 'A' && y[j] <= 'Z') {
    24. y[j] += 32;
    25. }
    26. }
    27. cnt[y]++;
    28. if (cnt[y] == 1) {
    29. m[y].id = y;
    30. m[y].sb = 0;
    31. m[y].sa = 0;
    32. m[y].st = 0;
    33. m[y].score = 0;
    34. }
    35. if (x[0] == 'A') {
    36. m[y].sa += s;
    37. } else if (x[0] == 'B') {
    38. m[y].sb += s;
    39. } else {
    40. m[y].st += s;
    41. }
    42. }
    43. for (map::iterator it = m.begin(); it != m.end(); it++) {
    44. (it->second).num = cnt[it->first];
    45. (it->second).score = (int)((it->second).sb * 1.0 / 1.5 + (it->second).sa * 1.0 + (it->second).st * 1.5);
    46. a[t++] = it->second;
    47. }
    48. sort(a, a + t, cmp);
    49. cout << t << endl;
    50. int rank = 1, temp = 0;
    51. cout << 1 << ' ' << a[0].id << ' ' << a[0].score << ' ' << a[0].num << endl;
    52. for (int i = 1; i < t; i++) {
    53. if (a[i].score == a[i - 1].score) {
    54. cout << rank << ' ' << a[i].id << ' ' << a[i].score << ' ' << a[i].num << endl;
    55. temp++;
    56. } else {
    57. rank += temp;
    58. cout << ++rank << ' ' << a[i].id << ' ' << a[i].score << ' ' << a[i].num << endl;
    59. temp = 0;
    60. }
    61. }
    62. return 0;
    63. }
  • 相关阅读:
    webSoket封装
    视频监控汇聚平台LntonCVS国标GB28181协议实现语音对讲功能
    嵌入式Linux应用开发-第十三章APP怎么读取按键值
    Activiti7 代码创建流程定义及生成bpmn及svg文件
    小程序如何添加打印机来打印订单
    PHP反序列化简单使用
    python制作自己的专属二维码
    【Redis】主从复制
    第5章 Java 高级特性
    Keytool配置 Tomcat的HTTPS双向认证
  • 原文地址:https://blog.csdn.net/weixin_53199925/article/details/128055905