QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575997#6785. What Kind of Friends Are You?RMapleRE 0ms3768kbC++171.4kb2024-09-19 17:48:312024-09-19 17:48:33

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 17:48:33]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3768kb
  • [2024-09-19 17:48:31]
  • 提交

answer

#include<bits/stdc++.h>
#include<set>
using namespace std;
const string No="Let's go to the library!!";
typedef struct Fname
{
	string name;
	string question;
}Friend;
Friend box[150];
void query(int n,int q)
{
	string a;
	char ch;
	for(int i=0;i<q;i++)
	{
		cin>>ch;
		a=a+ch;
	}
	//cout<<"a:"<<a<<endl;
	int flag=0;
	int ni,loc;
	for(ni=0;ni<n;ni++)
	{
		//cout<<box[ni].name<<": "<<box[ni].question<<endl;
		if(box[ni].question==a)
		{
			flag++;
			loc=ni;
		}
	}
	//cout<<"flag:"<<flag<<endl;
	if(flag!=1)
		cout<<No<<endl;
	else
		cout<<box[loc].name<<endl;
}
void solve()
{
	ios::sync_with_stdio(false);
	
	int n,q; cin>>n>>q;
	int friend_num; cin>>friend_num;
	for(int fi=0;fi<friend_num;fi++)
	{
		cin>>box[fi].name;
		box[fi].question="";
	}//将人名存入结构体
	string nm;
	for(int qqi=0;qqi<q;qqi++)
	{
		int fnum_this_round;
		cin>>fnum_this_round;
		set<string>name_this_round;
		for(int ffi=0;ffi<fnum_this_round;ffi++)
		{
			cin>>nm;
			name_this_round.insert(nm);
		}
		for(int nni=0;nni<friend_num;nni++)
		{
			if(name_this_round.count(box[nni].name)!=0)
				box[nni].question=box[nni].question+'1';
			else
				box[nni].question=box[nni].question+'0';
		}
	}
	for(int qqqi=0;qqqi<n;qqqi++)
		query(friend_num,q);
}
int main()
{
	int t;
	cin>>t;
	for(int ti=0;ti<t;ti++)
		solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3768kb

input:

2
3 4
5 Serval Raccoon Fennec Alpaca Moose
4 Serval Raccoon Alpaca Moose
1 Serval
1 Fennec
1 Serval
1 1 0 1
0 0 0 0
1 0 0 0
5 5
11 A B C D E F G H I J K
3 A B K
4 A B D E
5 A B K D E
10 A B K D E F G H I J
4 B D E K
0 0 1 1 1
1 0 1 0 1
1 1 1 1 1
0 0 1 0 1
1 0 1 1 1

output:

Serval
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
B
Let's go to the library!!
K

result:

ok 8 lines

Test #2:

score: -100
Runtime Error

input:

100
98 16
154 rliLiumEVQKkJNnMjAj qnhiLgzjsjRsu eiHrssJvVWBLaRFMQVo TwLVZsRNyEOysXY JtYpguJiCihuObMygLVt YiquXjVeDoe pSkLcJbceYhjx vrVgRvYziqmEpVJdB OYLIFEnoKsDXLtEpyRIF EKTKIOpwEswTWgvihdCa MCCudkhYJC wOkSGOgjZlWgf hTcqiMZqeBCjOmzAt dPWGKzHa iDWjhWBQsoQCInigoNIf qGXWZvcWVJvGUbZ oRLdhU NecdjCwFAikYe...

output:


result: