QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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)
Details
Tip: Click on the bar to expand more detailed information
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