QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#279543#5311. Master of Bothzzuqy#WA 10ms5616kbC++11907b2023-12-08 21:08:002023-12-08 21:08:01

Judging History

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

  • [2023-12-08 21:08:01]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:5616kb
  • [2023-12-08 21:08:00]
  • 提交

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'