QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#747315 | #5311. Master of Both | Moemi_ | WA | 92ms | 51952kb | C++20 | 1.9kb | 2024-11-14 16:52:29 | 2024-11-14 16:52:29 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <numeric>
#define sc_int(x) scanf("%d", &x)
#define x first
#define y second
#define pb push_back
using namespace std;
const int N = 5e5 + 10, M = 26, MOD = 80112002;
const int inf = 1e9;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef pair<char, int> PCI;
typedef pair<string, string> PSS;
LL n, m;
LL idx;
LL son[N][M], cnt2[N * M], cnt[N * M];
LL f[M][M];
void add(string s)
{
int cur = 0;
int len = s.length();
for(int i = 0; i < len; i ++)
{
if(!son[cur][s[i] - 'a']) son[cur][s[i] - 'a'] = ++ idx;
for(int j = 0; j < 26; j ++)
{
if(son[cur][j] && j != s[i] - 'a')
f[j][s[i] - 'a'] += cnt[son[cur][j]];
}
f[s[i] - 'a'][s[i] - 'a'] += cnt2[cur];
cur = son[cur][s[i] - 'a'];
cnt[cur] ++;
}
cnt2[cur] ++;
}
void solve()
{
cin >> n >> m;
vector<string> vec(n);
for(int i = 0; i < n; i ++)
{
cin >> vec[i];
}
for(auto t : vec) add(t);
while(m -- )
{
LL ans = 0;
string s;
cin >> s;
for(int i = 0; i < 26; i ++)
for(int j = 0; j <= i; j ++)
{
ans += f[s[i] - 'a'][s[j] - 'a'];
}
cout << ans << endl;
}
}
int main()
{
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int T = 1;
// cin >> T;
while(T --)
{
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
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: 47112kb
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: 92ms
memory: 51952kb
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'