QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#734735#9578. 爱上字典HygebraTL 47ms290624kbC++141.4kb2024-11-11 14:41:532024-11-11 14:41:53

Judging History

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

  • [2024-11-11 14:41:53]
  • 评测
  • 测评结果:TL
  • 用时:47ms
  • 内存:290624kb
  • [2024-11-11 14:41:53]
  • 提交

answer

//
// Created by THINKPAD on 2024/11/11.
//
#include <bits/stdc++.h>
using namespace std;
const int S=6000006;
int n,tot;
map<int, char> ch[S];
char a[S],b[22],c[S];
bool is[S];
void insert() {
    int p=0;
    for (int i=0;b[i];++i) {
        if (!ch[p][b[i]]) {
            ch[p][b[i]] = ++tot;
        }
        p = ch[p][b[i]];
    }
    is[p] = true;
}
bool pd() {
    bool ret = false;
    int p=0;
    for (int i=0;c[i];++i) {
        if (!ch[p][c[i]]) {
            ch[p][c[i]] = ++tot;
        }
        p = ch[p][c[i]];
    }
    if (!is[p]) ret = true;
    is[p] = true;
    return ret;
}
int main() {
    int len = 0;
    for (char c = getchar(); c!='\n'; c=getchar())
        a[len++] = c;
    a[len] = 0;
    for (int i=0;a[i];++i) {
        if (a[i]>='A' && a[i]<='Z') {
            a[i]=a[i]-'A'+'a';
        } else if (a[i]<'a' || a[i]>'z') {
            a[i]=' ';
        }
    }
    scanf("%d",&n);
    for (int i=1;i<=n;++i) {
        scanf("%s",b);
        insert();
    }
    int res=0,id = 0;
    while (id < len && sscanf(a + id,"%s",c)) {
        //puts(c);
        bool flag = true;
        for (int i=0;c[i];++i)
            if (c[i]>='a' && c[i]<='z') flag = false;
       // printf("%d %s\n",id,a+id);
        if (!flag && pd()) {
            ++res;
        }
        id += strlen(c) + 1;
        while (id<len && a[id]==' ') ++id;
    }
    printf("%d\n",res);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 44ms
memory: 289676kb

input:

I love Liaoning. Love Dalian!
1
love

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 43ms
memory: 290624kb

input:

Sulfox Loves Furry! Fur fur Furred.
2
anthropomorphic furry

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 47ms
memory: 289996kb

input:

Ginkgo leaves dance lightly and fall, reflecting the autumn light on the golden ground. Time is as peaceful as when we first met.
5
ginkgo reflect is as we

output:

17

result:

ok single line: '17'

Test #4:

score: -100
Time Limit Exceeded

input:

Eunuchism overterrible furbelow gantlet. Sophism thyroiditis thermoelectricity hassel misreward Barolong biradiated? Sweetie fatal delinquence unseemlily beamish inwork, azyme kamias Hans asteatosis synderesis champleve cheth? Dinitrile podial presentee! Waxmaker scleroscope ratably hectography lamp...

output:


result: