QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#763462#9578. 爱上字典renewRE 6ms10608kbPython3941b2024-11-19 20:24:372024-11-19 20:24:38

Judging History

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

  • [2024-11-19 20:24:38]
  • 评测
  • 测评结果:RE
  • 用时:6ms
  • 内存:10608kb
  • [2024-11-19 20:24:37]
  • 提交

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

output:


result: