• A Qualifiers Ranking Rules---The 2023 ICPC Asia Regionals Online Contest (1)


    The following is the current ranking rules for the ICPC Asia EC Online Qualifiers, and there will be two online contests.

    1. In each contest, only the rank of the top-ranked team from each university will be taken as the score of that university;
    2. In each contest, participating universities will be ranked according to their scores;
    3. The two rankings of universities are combined using the merge sorting method. For any two universities that obtain the same ranking in different contests, the university that received this ranking in the first contest will be ranked first.
    4. Delete duplicate universities and obtain the final ranking of all participating universities (only the highest rankings for each university are retained).

    Now assuming that there are n teams in the first contest and m teams in the second contest.

    For each contest, given the ranking of each team and the university to which it belongs, please output the final ranking of all participating universities according to the above rules.

    You can better understand this process through the sample.

    Input

    The first line contains two integers n,m (1≤n,m≤1e4) , representing the number of teams participating in the first contest and the second contest.

    Then following n lines, the i-th line contains a string si​ (1≤∣si​∣≤10) only consisting of uppercase letters, representing the abbreviation of the university to which the i-th ranked team in the first contest belongs.

    Then following m lines, the i-th line contains a string ti​ (1≤∣ti​∣≤10) only consisting of uppercase letters, representing the abbreviation of the university to which the i-th ranked team in the second contest belongs.

    It’s guaranteed that each university has only one abbreviation.

    Output

    Output several lines, the i-th line contains a string, representing the abbreviation of the i-th ranked university in the final ranking.

    You should ensure that the abbreviation of any participating universities appears exactly once.

    Input Sample

    1. 14 10
    2. THU
    3. THU
    4. THU
    5. THU
    6. XDU
    7. THU
    8. ZJU
    9. THU
    10. ZJU
    11. THU
    12. NJU
    13. WHU
    14. THU
    15. HEU
    16. PKU
    17. THU
    18. PKU
    19. PKU
    20. ZJU
    21. NUPT
    22. THU
    23. NJU
    24. CSU
    25. ZJU

    Output Sample

    1. THU
    2. PKU
    3. XDU
    4. ZJU
    5. NJU
    6. NUPT
    7. WHU
    8. HEU
    9. CSU

    Hint

    Sample is part of the results in 2022 ICPC Asia EC Online Contest.

    In the first contest, the ranking of the universities is:

    1. THU
    2. XDU
    3. ZJU
    4. NJU
    5. WHU
    6. HEU

    In the second contest, the ranking of the universities is:

    1. PKU
    2. THU
    3. ZJU
    4. NUPT
    5. NJU
    6. CSU

    By combining these two rankings according to the rules, the rankings of the universities is:

    1. THU
    2. PKU
    3. XDU
    4. THU
    5. ZJU
    6. ZJU
    7. NJU
    8. NUPT
    9. WHU
    10. NJU
    11. HEU
    12. CSU

    By deleting duplicate universities we will get the final ranking.

    解析:

            首先对于两个榜单,统计并且去重。

            然后对于榜单a和b进行遍历,并且记录是否重复。

            注意,有的学校可能没参加某一场,所以可能导致两场榜单去重之后长度不一样。

    1. #include
    2. using namespace std;
    3. typedef long long ll;
    4. const int N=1e5+5;
    5. int n,m;
    6. string s;
    7. vectora,b,res;
    8. setp;
    9. int main(){
    10. scanf("%d%d",&n,&m);
    11. for(int i=1;i<=n;i++){
    12. cin>>s;
    13. if(p.count(s)==0){
    14. p.insert(s);
    15. a.push_back(s);
    16. }
    17. }
    18. p.clear();
    19. for(int i=1;i<=m;i++){
    20. cin>>s;
    21. if(p.count(s)==0){
    22. p.insert(s);
    23. b.push_back(s);
    24. }
    25. }
    26. p.clear();
    27. for(int i=0;i<min(a.size(),b.size());i++){
    28. if(a[i]==b[i]){
    29. p.insert(a[i]);
    30. cout<
    31. }
    32. else{
    33. if(p.count(a[i])==0){
    34. cout<
    35. p.insert(a[i]);
    36. }
    37. if(p.count(b[i])==0){
    38. cout<
    39. p.insert(b[i]);
    40. }
    41. }
    42. }
    43. for(int i=min(a.size(),b.size());i<max(a.size(),b.size());i++){
    44. if(a.size()>b.size()){
    45. if(p.count(a[i])==0){
    46. p.insert(a[i]);
    47. cout<
    48. }
    49. }
    50. else{
    51. if(p.count(b[i])==0){
    52. p.insert(b[i]);
    53. cout<
    54. }
    55. }
    56. }
    57. return 0;
    58. }

  • 相关阅读:
    数字化时代的革新,浅谈数字化供应链究竟有何意义
    Rockchip Android修改uboot分区大小的方法
    ABAP读取销售订单选配BOM函数-CS_BOM_EXPL_KND_V1
    jenkins + gitlab + nginx 自动部署(webhook)
    Redis持久化机制
    Redis/Mysql知识概述
    ffplay源码分析:播放控制
    【JS】变量与数据类型,this
    R语言使用ggplot2可视化泊松回归模型(Poisson Regression)的结果、可视化不同参量组合下的计数结果
    Python从入门到实践(六)用户输入和while循环
  • 原文地址:https://blog.csdn.net/JungleZRD/article/details/132955222