QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#690238#5311. Master of BothTravelerCompile Error//C++201.8kb2024-10-30 21:10:492024-10-30 21:10:50

Judging History

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

  • [2024-10-30 21:10:50]
  • 评测
  • [2024-10-30 21:10:49]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<stdlib.h>
#include<unordered_map>
#include<vector>
#include<array>
#include<math.h>
#include<map>
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<string>
#include<limits.h>
#include<stack>
#include<set>
#include<list>
#include<algorithm>
#include <chrono>
#include<random>
using namespace std;

typedef long long LL;
#define int long long
typedef unsigned long long ULL;
typedef pair<LL, LL>PII;
typedef pair<double, double>PDD;
typedef pair<char, char>PCC;
LL n, m, k;

const LL inf = 1e18;
const LL N = 1e6 + 10;
const LL mod = 1e9 + 7;
const LL mod2 = 998244353;

int sum[26][26];
int tr[N * 13][26], tot, sz[N * 20];
string s;
int ans;
void inserts() {
    int p = 0;
    int len = s.size();
    for (int i = 0;i < len;i++) {
        int d = s[i] - 'a';
        if (tr[p][d] == 0)tr[p][d] = ++tot;
        for (int j = 0;j < 26;j++) {
            if (j == d)continue;
            sum[j][d] += sz[tr[p][j]];
        }

        p = tr[p][d];
        sz[p] += 1;
    }
    for (int i = 0;i < 26;i++) {
        ans += sz[tr[p][i]];
    }
}
void solve() {
    int q;
    cin >> n >> q;
    for (int i = 0;i < n;i++) {
        cin >> s;
        inserts();
    }
    while (q--) {
        string s;cin >> s;
        vector<int>pos(26);
        for (int i = 0;i < 26;i++) {
            pos[s[i] - 'a'] = i;
        }
        LL res = ans;
        for (int i = 0;i < 26;i++) {
            for (int j = 0;j < 26;j++) {
                if (pos[i] < pos[j]) {
                    res += sum[j][i];
                }
            }
        }
        cout << res << "\n";
    }
}
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Details

/tmp/cct9iaii.o: in function `inserts()':
answer.code:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/cct9iaii.o
/tmp/cct9iaii.o: in function `solve()':
answer.code:(.text+0x129): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cct9iaii.o
answer.code:(.text+0x168): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cct9iaii.o
answer.code:(.text+0x18f): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cct9iaii.o
answer.code:(.text+0x1b9): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/cct9iaii.o
answer.code:(.text+0x251): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/cct9iaii.o
collect2: error: ld returned 1 exit status