QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#279543 | #5311. Master of Both | zzuqy# | WA | 10ms | 5616kb | C++11 | 907b | 2023-12-08 21:08:00 | 2023-12-08 21:08:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int read()
{
int x;cin>>x;
return x;
}
int n,m;
string s;
int cnt[1000010],pos[300],sum;
ll f[300][300];
int tot,now;
int boy[1000010][26];
int main()
{
freopen("1.in","r",stdin);
n=read();m=read();
for(;n;n--)
{
cin>>s;
now=0;
for(auto x:s)
{
int t=x-'a';
if(boy[now][t]==0)
{
tot++;
boy[now][t]=tot;
}
for(int i=0;i<26;i++)
{
if(t==i)
continue;
f[i][t]+=cnt[boy[now][i]];
}
now=boy[now][t];
cnt[now]++;
}
for(int i=0;i<26;i++)
sum=sum+cnt[boy[now][i]];
}
for(;m;m--)
{
cin>>s;
ll ans=sum;
for(int i=0;i<26;i++)
pos[s[i]-'a']=i;
for(int i=0;i<26;i++)
{
for(int j=i+1;j<26;j++)
{
if(pos[i]>pos[j])
ans+=f[i][j];
else
ans+=f[j][i];
}
}
cout<<ans<<'\n';
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 10ms
memory: 5616kb
input:
5 3 aac oiputata aaa suikabudada aba abcdefghijklmnopqrstuvwxyz qwertyuiopasdfghjklzxcvbnm aquickbrownfxjmpsvethlzydg
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16...
result:
wrong answer 1st numbers differ - expected: '4', found: '0'