QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#699874 | #5311. Master of Both | Godwang | WA | 57ms | 29324kb | C++23 | 1.5kb | 2024-11-02 11:03:17 | 2024-11-02 11:03:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define endl '\n'
#define pii pair<int ,int >
#define ll long long
const int N=1e5+10,M=2e6+10;
int tt;
int n,qq;
string s;
ll yijing;
ll num[30][30];
struct node
{
ll jiewei;
int nxt[27];
ll sum;
}st[M];
int cnt=1;
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("ain.txt","r",stdin);freopen("aout.txt","w",stdout);
cin>>n>>qq;
//
//cout<<n<<" "<<qq<<endl;
// exit(0);
rep(i,1,n)
{
cin>>s;
int lens=s.size();
s=' '+s;
int now=1;
rep(j,1,lens)
{
yijing+=st[now].jiewei;
int nxt=s[j]-'a'+1;
rep(ii,1,26)
{
if(ii==nxt)
{
continue;
}
num[ii][nxt]+=st[ st[now].nxt[ii] ].sum;
}
if(st[now].nxt[nxt]==0)
{
st[now].nxt[nxt]=++cnt;
}
now=st[now].nxt[nxt];
st[now].sum++;
}
st[now].jiewei++;
}
while (qq--)
{
cin>>s;
s=' '+s;
ll ans=yijing;
per(i,1,26)
{
rep(j,1,i-1)
{
ans+=num[ s[i] -'a'+1 ][s[j]-'a'+1];
}
}
cout<<ans<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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: 4ms
memory: 29324kb
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: 57ms
memory: 22148kb
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:
61914935031 61946987587 61889415069 61957582687 61930977101
result:
wrong answer 1st numbers differ - expected: '61908555824', found: '61914935031'