Map will time out, two points ...
#include <iostream>#include<cstring>#include<cmath>#include<algorithm>#include<cstdio>#include<map>#include<queue>#include<string>#include<vector>using namespacestd;intn,m;intTot;vector<int>v[50000];structx{intID; intnum; Charname[ About][6];} s[2600];structname{Charname[6];} op[40010];BOOLCMP2 (ConstName&a,Constname&b) { returnstrcmp (A.name,b.name) <0;}BOOLcmpConstX&a,Constx&b) { returna.id<b.id;}Charquary[40010][6];intMain () {scanf ("%d%d",&n,&m); for(intI=1; i<=m;i++) {scanf ("%d",&s[i].id); scanf ("%d",&s[i].num); for(intj=1; j<=s[i].num;j++) scanf ("%s", S[i].name[j]); } for(intI=1; i<=n;i++) {scanf ("%s", Op[i].name); strcpy (Quary[i],op[i].name); } Sort (Op+1, op+1+N,CMP2); Sort (S+1, s+1+m,cmp); for(intI=1; i<=m;i++) { for(intj=1; j<=s[i].num;j++) { intH=0; intL=1, r=N; while(l<=r) {intMid= (L+R)/2; if(strcmp (Op[mid].name,s[i].name[j]) <0) l=mid+1; Else if(strcmp (op[mid].name,s[i].name[j]) >0) r=mid-1; Else{h=mid; Break; } } if(h==0)Continue; V[h].push_back (s[i].id); } } for(intI=1; i<=n;i++) { intq=0; intL=1, r=N; while(l<=r) {intMid= (L+R)/2; if(strcmp (Op[mid].name,quary[i]) <0) l=mid+1; Else if(strcmp (Op[mid].name,quary[i]) >0) r=mid-1; Else{Q=mid; Break; } } if(q==0)Continue; printf ("%s", Quary[i]); printf ("%d", V[q].size ()); for(intj=0; J<v[q].size (); j + +) printf ("%d", V[q][j]); printf ("\ n"); } return 0;}
PAT (Advanced level) 1039. Course List for Student