QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#639688 | #6785. What Kind of Friends Are You? | E_REMAL | WA | 2ms | 13448kb | C++14 | 1.3kb | 2024-10-13 21:33:38 | 2024-10-13 21:33:42 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int maxn=5e5;
int t,n,m,c,q;
string name[205];
int ans[205][30];
int ask[205][30];
string s;
int _find[205];//记录每个动物的回答能否指向唯一动物
int trie[maxn+5][5],cnt;
map <string , int> mp;
void _insert() {
for(int i=1;i<=c;i++) {
int p=0;
for(int j=1;j<=m;j++) {
if(trie[p][ans[i][j]]==-1) {
cnt++;
trie[p][ans[i][j]]=cnt;
}
p=trie[p][ans[i][j]];
}
if(trie[p][2]>0) trie[p][2]=-2;
if(trie[p][2]==-1) trie[p][2]=i;
}
}
void _search() {
for(int i=1;i<=n;i++) {
int p=0;
for(int j=1;j<=m;j++) {
p=trie[p][ask[i][j]];
}
//cout<<trie[p][2]<<"**"<<p<<endl;
if(trie[p][2]<0) cout<<"Let's go to the library!!"<<endl;
else cout<<name[trie[p][2]]<<endl;
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>t;
while(t--) {
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) ans[i][j]=0;
memset(trie,-1,sizeof(trie));
cnt=0;
cin>>c;
for(int i=1;i<=c;i++) {
cin>>name[i];
mp[name[i]]=i;
}
for(int i=1;i<=m;i++) {
cin>>q;
for(int j=1;j<=q;j++) {
cin>>s;
ans[mp[s]][i]=1;
}
}
_insert();//构建字典树
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
cin>>ask[i][j];
}
}
_search();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 13448kb
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!! K B Let's go to the library!! K
result:
wrong answer 4th lines differ - expected: 'Let's go to the library!!', found: ''