QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#734724 | #9578. 爱上字典 | Hygebra | WA | 41ms | 290852kb | C++14 | 1.4kb | 2024-11-11 14:37:19 | 2024-11-11 14:37:20 |
Judging History
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)) {
bool flag = true;
for (int i=0;c[i];++i)
if (c[i]>='a' && c[i]<='z') flag = false;
//printf("%d %s\n",n,c);
if (!flag && pd()) {
++res;
}
id += strlen(c) + 1;
}
printf("%d\n",res);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 31ms
memory: 290228kb
input:
I love Liaoning. Love Dalian! 1 love
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 41ms
memory: 290324kb
input:
Sulfox Loves Furry! Fur fur Furred. 2 anthropomorphic furry
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Wrong Answer
time: 31ms
memory: 290852kb
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:
18
result:
wrong answer 1st lines differ - expected: '17', found: '18'