QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#275584 | #5311. Master of Both | chitoge# | TL | 222ms | 29520kb | C++20 | 1.1kb | 2023-12-04 21:08:48 | 2023-12-04 21:08:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>> pex[1000005];
#define endl '\n'
int rex[30][30];
set<pair<int,int> > vis;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,q;cin>>n>>q;
string s;
for(int i=0;i<n;i++){
cin>>s;
for(int j=0;j<s.size();j++){
pex[j].push_back(make_pair(s[j]-'a',i));
}
}
for(int i=0;i<1000005;i++){
for(int j=1;j<pex[i].size();j++){
for(int k=0;k<j;k++){
if(vis.count(make_pair(pex[i][j].second,pex[i][k].second)))continue;
if(pex[i][j].first!=pex[i][k].first){
rex[pex[i][j].first][pex[i][k].first]++;
vis.insert(make_pair(pex[i][j].second,pex[i][k].second));
}
}
}
}
for(int i=0;i<q;i++){
string s;
cin>>s;
long long ans=0;
for(int l=0;l<26;l++){
for(int r=l+1;r<26;r++){
ans+=rex[s[l]-'a'][s[r]-'a'];
}
}
cout<<ans<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 26948kb
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: 222ms
memory: 29520kb
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
Time Limit Exceeded
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...