QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#625045 | #7618. Pattern Search | Abrin | WA | 15ms | 10740kb | Python3 | 762b | 2024-10-09 17:14:37 | 2024-10-09 17:14:38 |
Judging History
answer
def max_pattern_occurrences(s, t):
count_s = [0] * 26
count_t = [0] * 26
for char in s:
count_s[ord(char) - ord('a')] += 1
for char in t:
count_t[ord(char) - ord('a')] += 1
for i in range(26):
if count_t[i] > 0 and count_s[i] < count_t[i]:
return 0
max_repeats = float('inf')
for i in range(26):
if count_t[i] > 0:
max_repeats = min(max_repeats, count_s[i] // count_t[i])
return max_repeats
def main():
z = int(input())
results = []
for _ in range(z):
s, t = input().split()
results.append(str(max_pattern_occurrences(s, t)))
print("\n".join(results))
if __name__ == "__main__":
main()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 10584kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 10740kb
input:
16 a a a b b a aa a ab aa ab b ab c aaz az abcde edcba aaaaaaaaaaaabbb aaaaaaaaabb aaaaaazz az aaaaaaaaaz zzzzz gggggggggggggggggggge ggggeeee hyphyphyphyphyphyphyphyphyphyphyphyp eeeeeeeeee hyphyphyphyphyphyphyphyphyphyphyphype eeteeteeteet aaaabbbbbbcccccccc aaabbbbbcccccc
output:
1 0 0 2 0 1 0 1 1 1 2 0 0 0 0 1
result:
wrong answer 10th numbers differ - expected: '2', found: '1'