QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#763462 | #9578. 爱上字典 | renew | RE | 6ms | 10608kb | Python3 | 941b | 2024-11-19 20:24:37 | 2024-11-19 20:24:38 |
Judging History
answer
def is_alpha(c):
return c.isalpha() # Returns True if the character is alphabetic (a-z or A-Z)
# Read the input string
s = input().strip()
# Read the number of words in the "vis" dictionary
n = int(input())
# Dictionary to track visited words
vis = {}
# Read 'n' words and mark them as visited
for _ in range(n):
t = input().strip()
vis[t] = True
ans = 0 # Counter for new words
i = 0
while i < len(s):
p = ""
# Skip non-alphabetic characters
while i < len(s) and not is_alpha(s[i]):
i += 1
# Collect alphabetic characters to form a word
while i < len(s) and is_alpha(s[i]):
p += s[i]
i += 1
if p:
# Convert the word to lowercase
p = p.lower()
# If the word is not in vis, count it as a new word
if p not in vis:
vis[p] = True
ans += 1
# Output the result
print(ans)
詳細信息
Test #1:
score: 100
Accepted
time: 6ms
memory: 10608kb
input:
I love Liaoning. Love Dalian! 1 love
output:
3
result:
ok single line: '3'
Test #2:
score: -100
Dangerous Syscalls
input:
Sulfox Loves Furry! Fur fur Furred. 2 anthropomorphic furry