求调!
查看原帖
求调!
814343
bc2_cryeggy楼主2023/2/17 22:45

代码:

#include<bits/stdc++.h>
using namespace std;
#define qwq ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//map 好闪,拜谢 map 
int n, m, b[100010];
map<string, vector<int>> mp;

int main()
{
	qwq;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int l;
		cin >> l;
		for (int j = 1; j <= l; j++)
		{
			string word;
			cin >> word;
			mp[word].push_back(i);
		}
	}
	cin >> m;
	for (int i = 1; i <= m; i++)
	{
		string found;
		cin >> found;
		memset (b, 0, sizeof(b));
		for (int j = 0; j < mp[found].size(); j++)
		{
			if (b[mp[found][j]] == 0) 
			{
				cout << mp[found][j] << " ";
				mp[found][j] = 1;
			}
		}
		cout << endl;
	}
	return 0;
}
2023/2/17 22:45
加载中...