标签:不能 学生 std sort char s har sdi dig i++
水题,但是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)
标签:不能 学生 std sort char s har sdi dig i++
原文地址:http://www.cnblogs.com/jihe/p/6127125.html