一道蓝题爆搜能过?
查看原帖
一道蓝题爆搜能过?
341245
xrk2006楼主2021/8/23 11:51

RT,当时本来想先写个暴力骗点暴力分的,结果AC了??

代码如下:

//luoguP3879
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=1005;
string s[maxn][maxn];
int l[maxn];

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int main()
{
	int n,m;
	n=read();
	for(int i=1;i<=n;i++)
	{
		l[i]=read();
		for(int j=1;j<=l[i];j++)cin>>s[i][j];
	}
	m=read();
	while(m--)
	{
		string a;
		cin>>a;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=l[i];j++)if(s[i][j]==a){cout<<i<<" ";break;}
		}
		cout<<endl;
	}
	return 0;
}

AC记录:100pts

2021/8/23 11:51
加载中...