QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#730583 | #5311. Master of Both | xueman | Compile Error | / | / | C++23 | 1.4kb | 2024-11-09 20:44:37 | 2024-11-09 20:44:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const int N = 1000 + 10;
const int maxn = 5e6 + 10;
const int inf = 0x3f3f3f3f;
int pos[32];
ll sum[maxn][32], cnt[maxn][32];
struct Trie
{
int ch[maxn][32];
int idx = 0;
Trie() { memset(ch, 0, sizeof(ch)); }
void insert(const string &s)
{
int u = 0;
for (int i = 0; i < s.size(); i++)
{
int v = s[i] - 'a' + 1;
if (!ch[u][v])
ch[u][v] = ++idx;
for (int j = 0; j < 27; j++)
sum[j][v] += cnt[u][j];
cnt[u][v]++;
u = ch[u][v];
}
}
} t;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, Q;
cin >> n >> Q;
for (int i = 1; i <= n; i++)
{
string s;
cin >> s;
s += 'a' - 1;
t.insert(s);
}
while (Q--)
{
string s;
cin >> s;
s = char('a' - 1) + s;
for (int i = 0; i < s.size(); i++)
pos[s[i] - 'a' + 1] = i;
ll ans = 0;
for (int i = 0; i < s.size(); i++)
{
for (int j = 0; j < s.size(); j++)
{
if (pos[i] > pos[j])
ans += sum[i][j];
}
}
cout << ans << endl;
}
}
詳細信息
/tmp/ccVeFcZX.o: in function `main': answer.code:(.text.startup+0x204): relocation truncated to fit: R_X86_64_PC32 against symbol `pos' defined in .bss section in /tmp/ccVeFcZX.o answer.code:(.text.startup+0x438): relocation truncated to fit: R_X86_64_PC32 against symbol `pos' defined in .bss section in /tmp/ccVeFcZX.o collect2: error: ld returned 1 exit status