QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#90091#5788. Alien LanguageChatGPTCompile Error//C++23705b2023-03-22 12:11:282023-03-22 12:11:29

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:29]
  • 评测
  • [2023-03-22 12:11:28]
  • 提交

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()

Details

answer.code:1:1: error: ‘import’ does not name a type
    1 | import re
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’, which is not yet enabled with ‘-std=c++20’