QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#693260 | #5311. Master of Both | the_fool# | WA | 81ms | 26376kb | C++20 | 1.1kb | 2024-10-31 15:50:13 | 2024-10-31 15:50:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ll = long long;
int n,q;
int trie[1000005][26],cnt[1000005],id;
int num[26][26],k;
bool vis[26];
void insert(string s)
{
int p=0,l=s.size();
for(int i=0;i<l;i++)
{
int x=s[i]-'a';
if(trie[p][x]==0)trie[p][x]=++id;
for(int y=0;y<26;y++)
{
if(y==x)continue;
int p1=trie[p][y];
if(p1==0)continue;
num[x][y]+=cnt[p1];
}
p=trie[p][x];
cnt[p]++;
}
for(int y=0;y<26;y++)
if(trie[p][y])k+=cnt[trie[p][y]];
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>q;
for(int i=1;i<=n;i++)
{
string s;
cin>>s;
insert(s);
}
while(q--)
{
string mp;
cin>>mp;
memset(vis,0,sizeof(vis));
int ans=k;
for(int i=0;i<26;i++)
{
int t=mp[i]-'a';
for(int j=0;j<26;j++)
if(vis[j]==0)ans+=num[t][j];
vis[t]=1;
}
cout<<ans<<endl;
}
}
/*
5 3
aac
oiputata
aaa
suikabudada
aba
abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
aquickbrownfxjmpsvethlzydg
2 1
aaa
aa
abcdefghijklmnopqrstuvwxyz
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3560kb
input:
5 3 aac oiputata aaa suikabudada aba abcdefghijklmnopqrstuvwxyz qwertyuiopasdfghjklzxcvbnm aquickbrownfxjmpsvethlzydg
output:
4 3 4
result:
ok 3 number(s): "4 3 4"
Test #2:
score: 0
Accepted
time: 7ms
memory: 26376kb
input:
100 100 spkfvrbkfsspmnlgrdojwdqutknvzejorqxsmfgbfrhpxkrrtravhmxenjrzypkxounrbantpkaezlcnudjmwxpgqakfoxcmdjcygujdtpluovbisxmklkzzuuyziapzyrszcggjkzrwmtyolnbobubbezdwmumyzyhaogiiolictzjpxbyaamecytpnyzxlumxjkzyfavxlzdwtgrxtqcnddzfocznitlaxlpcceuelqlbmyzetlpaivxnuvuctsbjbaulmbmkangqahpdojqimvmcugjeczkgx...
output:
2368 2693 2179 2466 2435 2370 2604 2468 2335 2268 2686 2781 2538 2208 2386 2539 2728 2383 2248 2372 2446 2266 2290 2688 2602 2515 2634 2558 2598 2632 2763 2255 2557 2579 2367 2516 2676 2273 2429 2556 2576 2635 2422 2829 2362 2552 2377 2261 2603 2516 2298 2282 2520 2333 2505 2287 2261 2476 2791 2328 ...
result:
ok 100 numbers
Test #3:
score: -100
Wrong Answer
time: 81ms
memory: 18284kb
input:
500000 5 ru x tb s e w e m l b g zr jp h js xk fjwtk wtkem o ev a a x sy dh y kkdcxfr hgq j k xr s cvwbrlk u u x wtvgef dzxsk qv gxl g m rpl ldp q lc dk g k im o yhn z a knc tyv mz ak qdhq c niw o j heu w g e kt n inqt i al q ebphky sv m mry oj cl j r sf vpd u rio sfkg m el s zs g o e njp r xczcm gh...
output:
1779013680 1811066236 1753493718 1821661336 1795055750
result:
wrong answer 1st numbers differ - expected: '61908555824', found: '1779013680'