Wow this question is really pit, originally I thought it was just an innocent map <string, set>
Last point overtime ooo
suddenly glimpse, found the topic full of meaning, and fixed four-digit number, and the top three after a letter is the number? Why so clearly defined, oh no that this character is a 26 decimal yet? ? !
Scared, so change it before. . .
code show as below
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
vector < int > query [MAXN];//查询
int num [MAXN]; // 人数
int turn ( string s) //转为26进制数
{
int k = 0;
for (int i = 0; i < 4; i++)
{
if(i == 3) k = k * 26 + s[i] - '0';
else k = k*26 + s[i] - 'A';
}
return k;
}
int main()
{
int n,m;
string name;
scanf("%d%d",&n,&m);
for (int i = 0; i < m; i++)
{
int room,ren;
string s;
scanf("%d%d",&room,&ren);
for ( int j = 0; j < ren; j++ )
{
cin >> s;
int h = turn(s);
query[h].push_back(room);
num[h]++;
}
}
for (int i = 0; i < n; i++)
{
cin >> name;
int h = turn(name);
cout << name << " " << num[h] ;
sort(query[h].begin(),query[h].end());
for (int j = 0 ; j < num[h]; j++)
printf(" %d",query[h][j]);
cout << endl;
}
return 0;
}