QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90092#5788. Alien LanguageChatGPT33 ✓596ms10064kbPython3705b2023-03-22 12:11:502023-03-22 12:11:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-22 12:11:51]
  • 评测
  • 测评结果:33
  • 用时:596ms
  • 内存:10064kb
  • [2023-03-22 12:11:50]
  • 提交

answer

import re

def count_pattern_matches(L, D, N, words, patterns):
    results = []
    for pattern in patterns:
        regex_pattern = pattern.replace('(', '[').replace(')', ']')
        regex = re.compile(regex_pattern)
        matches = sum(1 for word in words if regex.fullmatch(word))
        results.append(matches)
    return results

def main():
    L, D, N = map(int, input().split())
    words = [input().strip() for _ in range(D)]
    patterns = [input().strip() for _ in range(N)]

    results = count_pattern_matches(L, D, N, words, patterns)

    for i, result in enumerate(results, start=1):
        print(f"Case #{i}: {result}")

if __name__ == "__main__":
    main()

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 19ms
memory: 8980kb

input:

10 25 10
ubjwqxhwfd
myzbivqwwd
mdynwjlxby
swbburyeqf
hcdignewka
byfzobkbym
zskbvgutkk
arpdavrgtd
gudnwrogsp
uuhexdnryx
ebrtetqxzl
chfgubziks
zemjlloycm
xgpobuhtti
ewpkejndux
xtelepwsnb
hmhwblskem
tjkivquitq
itlmeqddis
epelmfwesd
slmcthspro
fbjrpnhsqr
kuhpitwgzo
jszvwvermw
hsxqlndufw
lsssjcnfjn
g(rsu...

output:

Case #1: 0
Case #2: 1
Case #3: 0
Case #4: 1
Case #5: 5
Case #6: 6
Case #7: 1
Case #8: 4
Case #9: 1
Case #10: 5

result:

ok 10 lines

Subtask #2:

score: 23
Accepted

Test #2:

score: 23
Accepted
time: 596ms
memory: 10064kb

input:

15 5000 500
ubjwqxhwfdmyzbi
vqwwdmdynwjlxby
swbburyeqfhcdig
newkabyfzobkbym
zskbvgutkkarpda
vrgtdgudnwrogsp
uuhexdnryxebrte
tqxzlchfgubziks
zemjlloycmxgpob
uhttiewpkejndux
xtelepwsnbhmhwb
lskemtjkivquitq
itlmeqddisepelm
fwesdslmcthspro
fbjrpnhsqrkuhpi
twgzojszvwvermw
hsxqlndufwlsssj
cnfjnwsfvqdsuuf
...

output:

Case #1: 0
Case #2: 1
Case #3: 0
Case #4: 1
Case #5: 735
Case #6: 371
Case #7: 1
Case #8: 355
Case #9: 1
Case #10: 547
Case #11: 0
Case #12: 1
Case #13: 0
Case #14: 1
Case #15: 279
Case #16: 528
Case #17: 1
Case #18: 450
Case #19: 1
Case #20: 477
Case #21: 0
Case #22: 1
Case #23: 0
Case #24: 1
Case ...

result:

ok 500 lines

Extra Test:

score: 0
Extra Test Passed