QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#168311#7076. Browser Gamessupepapupu#WA 2ms9088kbC++171.4kb2023-09-08 09:02:362023-09-08 09:02:37

Judging History

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

  • [2023-09-08 09:02:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9088kb
  • [2023-09-08 09:02:36]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 5e4 + 10, M = N * 50;

int tr[M][28], unrel[M], res[M], idx;
string str[N];

inline int get(char c) {
    if ('a' <= c && 'z' >= c) return c - 'a';
    return 26 + (c == '.');
}

void insert(int id) {
    int p = 0;
    for (char c: str[id]) {
        ++unrel[p];
        int t = get(c);
        if (!tr[p][t]) tr[p][t] = ++idx;
        p = tr[p][t];
    }
}

void change(int p, int id, int k) {
    if (k == str[id].size()) {
        res[p] = 1;
        return;
    }
    --unrel[p];
    int t = get(str[id][k]);
    if (!unrel[p]) {
        if (p) res[p] = 1;
        else {
            res[p] = 0;
            for (int i = 0; i < 28; ++i) 
                if (tr[p][i]) ++res[p];
        }
        return;
    }
    change(tr[p][t], id, k + 1);
    res[p] = 0;
    for (int i = 0; i < 28; ++i) 
        if (tr[p][i]) {
            res[p] += res[tr[p][i]];    
        }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> str[i];
        insert(i);
    }
    if (n == 1) {
        cout << "0\n";
        return 0;
    }
    for (int i = 1; i <= n; ++i) {
        change(0, i, 0);
        cout << res[0] << el;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9088kb

input:

3
ufoipv.ofu
hsbocmvfgboubtz.kq
hfotijo.njipzp.dpn/kb

output:

1
2
2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 8828kb

input:

3
hfotijo.njipzp.dpn/kb
hsbocmvfgboubtz.kq
ufoipv.ofu

output:

1
1
2

result:

ok 3 lines

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 8908kb

input:

1
a

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'