map
应该是用红黑树写的吧,空间是多少呢?
这道题为什么不能用map
直接过?
#include <string>
#include <map>
#include <iostream>
#include <cstdio>
using namespace std;
int q, m, n;
string st;
map <string, int> f[1005];
int main(){
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> q;
for(int j = 1; j <= q; j++){
cin >> st;
if(f[i][st] == 0)
f[i][st] = 1;
}
}
cin >> m;
for(int i = 1; i <= m; i++){
cin >> st;
for(int j = 1; j <= n; j++)
if(f[j][st] >= 1)
cout << j << " ";
cout << endl;
}
return 0;
}
数据范围: m≤104,n≤103,∣st∣≤20