QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#732371#7076. Browser GamesYurily#RE 1ms9988kbC++201.4kb2024-11-10 14:13:412024-11-10 14:13:42

Judging History

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

  • [2024-11-10 14:13:42]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:9988kb
  • [2024-11-10 14:13:41]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 5e4;
const int M = 50;
const int L = 29;       //'a'-'z','.','/',nth
const int T = 1e6;
int ans=0,cnt[N+3];

int c2i(char c){
    if('a' <= c && c <= 'z')
        return c - 'a';
    if(c == '.')
        return 26;
    if(c == '/')
        return 27;
    return -1;
}

char i2c(int i){
    if(i < 26)
        return i + 'a';
    if(i == 26)
        return '.';
    if(i == 27)
        return '/';
    return '!';
}

    int n;
    int tot, t[T + 3][L + 3], l[T + 3], r[T + 3];
    int fa[T+3],ed[N+3];
    char s[M + 3];
    bool tag[T+3];
void push(int kk,char *s){
    int n = strlen(s);
    int u = 1;
    for(int i = 0; i < n; i++){
        int c=c2i(s[i]);
        if(!t[u][c]){
            t[u][c]=++tot;     
            fa[tot]=u; 
            r[u]++;  
        }
        u=t[u][c];
    }
    tag[u]=1;
    ed[kk]=u;
}

void sol(int tmp){
    int s=tmp;
    cnt[fa[s]]++;
    while(cnt[fa[s]]==r[fa[s]]&&fa[s]!=1){
        ans=ans-r[fa[s]]+1;
        s=fa[s];
        cnt[fa[s]]++;
    }
}

int main(){
    scanf("%d\n", &n);
    
    tot = 2;
    t[1][28] = 2;
    for(int kk = 1, m; kk <= n; kk++){
        scanf("%s", s);
        push(kk,s);
    }
    for(int i=1;i<=n;i++){
        ans++;
        sol(ed[i]);
        cout<<ans<<"\n";
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7892kb

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: 9876kb

input:

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

output:

1
1
2

result:

ok 3 lines

Test #3:

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

input:

1
a

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 9876kb

input:

2
a
b

output:

1
2

result:

ok 2 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 9844kb

input:

3
a.b/e
a.c/e
a.d/e

output:

1
2
1

result:

ok 3 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 9872kb

input:

5
wow
war
world
red
glasses

output:

1
2
1
2
3

result:

ok 5 lines

Test #7:

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

input:

28
aa
ab
ac
ad
ae
af
ag
ah
ai
aj
ak
al
am
an
ao
ap
aq
ar
as
at
au
av
aw
ax
ay
az
b
cd

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1
2
3

result:

ok 28 lines

Test #8:

score: -100
Runtime Error

input:

50000
aaab
aaac
aaad
aaae
aaaf
aaag
aaah
aaai
aaaj
aaak
aaal
aaam
aaan
aaao
aaap
aaaq
aaar
aaas
aaat
aaau
aaav
aaaw
aaax
aaay
aaaz
aaba
aabb
aabc
aabd
aabe
aabf
aabg
aabh
aabi
aabj
aabk
aabl
aabm
aabn
aabo
aabp
aabq
aabr
aabs
aabt
aabu
aabv
aabw
aabx
aaby
aabz
aaca
aacb
aacc
aacd
aace
aacf
aacg
aach...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
4
5
6
7
8
9
10
11
12
13
14
...

result: