QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#576015 | #6785. What Kind of Friends Are You? | RMaple | RE | 1ms | 3776kb | C++17 | 1.3kb | 2024-09-19 17:55:34 | 2024-09-19 17:55:37 |
Judging History
answer
#include<bits/stdc++.h>
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;
}
int flag=0;
int ni,loc;
for(ni=0;ni<n;ni++)
{
if(box[ni].question==a)
{
flag++;
loc=ni;
}
}
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3776kb
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...