QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340409#7780. Dark LaTeX vs. Light LaTeXAITU 0 (Altair Ashurov, Almaz Shinbay, Zhambyl Maksotov)Compile Error//C++232.2kb2024-02-28 23:37:222024-02-28 23:37:22

Judging History

This is the latest submission verdict.

  • [2024-11-25 20:53:52]
  • hack成功,自动添加数据
  • (/hack/1258)
  • [2024-02-28 23:37:22]
  • Judged
  • [2024-02-28 23:37:22]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

typedef long long ll;

mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());

const int N = 5e3 + 2;
const int M = 12.5e6 + 2;

string s[2];
int now[N], pp[2][N];
map<char, int> go[2][M];
vector<int> is[2][M];
int pos[2][M], leaf[2], col[2][N][N];
int sz[2], cnt[2][M];
long long ans = 0;

void add(int i, int p) {
    int v = 0;
    for (int j = i; j < sz(s[p]); ++j) {
        char c = s[p][j];
        if (go[p][v].count(c) == 0) go[p][v][c] = ++sz[p];
        v = go[p][v][c];
        cnt[p][v]++;
        is[p][v].push_back(j);
    }
    if (pos[p][v] == 0)
        pos[p][v] = ++leaf[p];
}

void dfs(int v, int p) {
    for (auto i : is[p][v]) now[i]++;
    if (pos[p][v]) {
        for (int i = 0; i < sz(s[p]); ++i)
            col[p][pos[p][v]][i] = now[i];
    }
    for (auto [c, u] : go[p][v])
        dfs(u, p);
    for (auto i : is[p][v]) now[i]--;
}

int posl(int i, int p) {
    int v = 0;
    for (int j = i; j < sz(s[p]); ++j) {
        int c = s[p][j];
        v = go[p][v][c];
    }
    return v;
}


void get(int i, int p) {
    int v = 0;
    int q = p ^ 1;
    for (int j = i; j < sz(s[p]); ++j) {
        char c = s[p][j];
        if (go[q][v].count(c) == 0) break;
        v = go[q][v][c];
        if (i > 0 && j + 1 < sz(s[p]))
            ans += cnt[q][v] * col[p][pp[p][j + 1]][i - 1];
        if (q == 1) ans += cnt[q][v];
    }
}

int main() {
    //cin >> s[0] >> s[1];
    s[0] = string(5000, 'a');
    s[1] = string(5000, 'a');
    for (auto &c : s[0]) 
        c = "ab"[bruh() % 2];
    for (auto &c : s[1]) 
        c = "ab"[bruh() % 2];
    for (int k = 0; k < 2; ++k) {
        for (int i = 0; i < sz(s[k]); ++i)
            add(i, k);
        dfs(0, k);
        for (int i = 0; i < sz(s[k]); ++i) {
            int l = pos[k][posl(i, k)];
            pp[k][i] = l;
        }
    }

    for (int k = 0; k < 2; ++k)
        for (int i = 0; i < sz(s[k]); ++i)
            get(i, k);

    cout << ans << '\n';
}


Details

/tmp/ccQ9ptXR.o: in function `__tcf_0':
answer.code:(.text+0x11b): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x12e): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x13e): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x145): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x151): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccQ9ptXR.o
/tmp/ccQ9ptXR.o: in function `dfs(int, int)':
answer.code:(.text+0x3f1): relocation truncated to fit: R_X86_64_PC32 against symbol `now' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x4e7): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x51f): relocation truncated to fit: R_X86_64_PC32 against symbol `now' defined in .bss section in /tmp/ccQ9ptXR.o
answer.code:(.text+0x574): relocation truncated to fit: R_X86_64_PC32 against symbol `now' defined in .bss section in /tmp/ccQ9ptXR.o
/tmp/ccQ9ptXR.o: in function `posl(int, int)':
answer.code:(.text+0x6cc): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status