zoukankan      html  css  js  c++  java
  • PAT:1039. Course List for Student (25) 部分正确(最后一个大数据错误)

    #include<stdio.h>
    #include<string.h>
    #include<vector>
    #include<algorithm>
    using namespace std;
    const int MAX=40010;
    const int H=26*26*26*10+10;
    int n,k;          //n个人,k门课
    
    vector<int> HAR[H];
    
    int getID(char str[])    //获取名字对应的哈希ID
    {
      int ID=0;
      for(int i=0 ; i<3 ; ++i)
      {
        ID=ID*26+str[i]+'0';
      }
      ID+=str[3]+'0';
      return ID;
    }
    
    int main()
    {
      scanf("%d%d",&n,&k);
      for(int i=1 ; i<=k ; ++i)
      {
        int course=0,people=0;
        scanf("%d%d",&course,&people);
        for(int j=0 ; j<people ; ++j)
        {
          char name[5];
          scanf("%s",name);
          int ID=getID(name);
          HAR[ID].push_back(course);
        }
      }
      for(int i=0 ; i<n ; ++i)
      {
        char name[5];
        scanf("%s",name);
        int ID=getID(name);
        sort(HAR[ID].begin(),HAR[ID].end());
        printf("%s %d",name,HAR[ID].size());
        for(int j=0 ; j<HAR[ID].size() ; ++j)
          printf(" %d",HAR[ID][j]);
        printf("
    ");
      }
    
      return 0;
    }
  • 相关阅读:
    【笔记】Maven使用入门
    【笔记】c++文件
    【笔记】IntelliJ IDEA配置Hibernate
    【HTML5校企公益课】第四天
    【c++习题】【17/4/16】动态分配内存
    C#
    C#
    C#
    C#
    C#
  • 原文地址:https://www.cnblogs.com/Evence/p/4326678.html
Copyright © 2011-2022 走看看