求助,WA
查看原帖
求助,WA
894318
ilililli楼主2023/11/5 22:27
#include<algorithm>
#include<iostream>
#include<typeinfo>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>

#include<unordered_map>
#include<unordered_set>

namespace fast_IO
{
	template <typename T> inline void write(T x)
	{
		if ( x < 0 ) putchar('-'), x = -x;
		if ( x == 0 )
		{
			putchar('0');
			return;
		}
		if ( x > 9 ) write(x/10);
		putchar(x % 10 + '0');
		return;
	}
	template <typename T> inline void read(T &x)
	{
		x = 0; int w = 1; char ch = getchar();
		while ( !isdigit(ch) )
		{
			if ( ch == '-' ) w = -1; ch = getchar();
		}
		while ( isdigit(ch) )
			x = (x<<1) + (x<<3) + (ch^48), ch = getchar();
		x *= w;
		return;
	}
}
using namespace fast_IO;
using namespace std;
using ll = long long;

#define writel(x) write(x),putchar('\n')
#define writes(x) write(x),putchar(' ')

const int MAXN = 5e3+5;
int n, m, cnt;
bool a[1005][MAXN];
unordered_map<string, int> unp;

int main()
{
	read(n);
	for (int i=1; i<=n; i++)
	{
		int l;
		read(l);
		string s;
		for (int j=1; j<=l; j++)
		{
			cin >> s;
			if (unp[s] == 0) unp[s] = ++cnt;
			if (unp[s] != 0) a[i][unp[s]] = true;
		}
	}
//	for (auto it = unp.begin(); it != unp.end(); ++it)
//	{
//		cout << it->first << ' ' << it->second << endl;
//	}
//	for (int i=0; i<=3; i++)
//	{
//		for (int j=1; j<=30; j++)
//		{
//			cout << a[i][j] << ' ';
//		}
//		cout << endl;
//	}
	read(m);
	for (int i=1; i<=m; i++)
	{
		string s;
		cin >> s;
		for (int i=1; i<=n; i++)
		{
			if (a[i][unp[s]])
			{
				writes(i);
			}
		}
		puts("");
	}
	return 0;
}

2023/11/5 22:27
加载中...