PAT1039. Course List for Student (25)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT1039. Course List for Student (25)相关的知识,希望对你有一定的参考价值。

水题,但是oj有毒,内存用了1/4,没炸内存,vector也开的够大,莫名给我个段错误,好烦

不能存学生的名字,存了,最后一组测试就给一个段错误,烦

#include<bits/stdc++.h>
using namespace std;
const int maxn=180000;
vector<short> v[maxn];
char s[10];
int convert(char c){
    if(isdigit(c))return c-‘0‘;
    return c-‘A‘+10;
}
int Hash(){
    int res=(s[0]-‘A‘)*26*26*10+(s[1]-‘A‘)*26*10+(s[2]-‘A‘)*10+(s[3]-‘0‘);
    return res;
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    while(m--){
        int a,b;
        scanf("%d%d",&a,&b);getchar();
        while(b--){
            scanf("%s",s);
            int res=Hash();
            v[res].push_back(a);
        }
    }
    for(int i=0;i<n;i++){
        scanf("%s",s);
        int num=Hash();
        printf("%s %d",s,v[num].size());
        sort(v[num].begin(),v[num].end());
        for(auto x: v[num])printf(" %d",x);
        putchar(‘\n‘);
    }
    return 0;
}

  

以上是关于PAT1039. Course List for Student (25)的主要内容,如果未能解决你的问题,请参考以下文章