Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Number of test cases num_test_cases = int(input()) for i in range(num_test_cases): # Word length and number of words for this test case length, num_words

image text in transcribed

# Number of test cases num_test_cases = int(input())

for i in range(num_test_cases): # Word length and number of words for this test case length, num_words = [int(x) for x in input().split()] # Get the words in the vocabulary for this test case words = [input().strip() for x in range(num_words)] # Number of patterns for this test case num_patterns = int(input()) for j in range(num_patterns): pattern = input().strip()

Checker:

550d 0d0a 0000 0000 c144 5160 2a11 0000 e300 0000 0000 0000 0000 0000 0000 0000 0007 0000 0040 0000 0073 4005 0000 6400 6401 6c00 5a00 6400 6401 6c01 5a01 6400 6401 6c02 5a02 6400 6402 6c03 6d03 5a03 0100 6403 5a04 6404 5a05 6405 5a06 6406 6407 6408 6409 6704 5a07 6503 a008 a100 5a08 6508 6a09 6504 6b02 5a0a 6505 6508 6a0b 6b01 6f60 6508 6a0b 6506 6b01 5a0c 650a 726a 650c 737a 650d 640a 8301 0100 6501 a00e a100 0100 640b 640c 8400 6501 6a0f 640d 6401 8502 1900 4400 8301 5a10 6511 6510 8301 6400 6b02 73aa 6510 6400 1900 6507 6b07 72ca 650d 640e 8301 0100 650d 640f 6410 a012 6507 a101 8302 0100 6501 a00e a100 0100 6510 6400 1900 5a13 6411 6513 1600 5a14 6500 6a15 a016 6514 a101 73fa 650d 6412 6514 1600 8301 0100 6501 a00e a100 0100 6502 a002 a100 5a17 650d 6413 6513 8302 0100 6414 6513 1600 5a18 6415 6513 1600 5a19 6416 6513 1600 5a1a 650d 6417 8301 0100 6418 6514 1700 6419 1700 6518 1700 641a 1700 651a 1700 5a1b 6500 a01c 651b a101 0100 650d 641b 8301 0100 6513 6409 6b02 9004 725e 651d 6519 8301 5a1e 641c 640c 8400 651e a01f a100 4400 8301 5a20 651e a021 a100 0100 651d 651a 8301 5a22 651d 6518 8301 5a1e 6400 5a23 6524 651e a025 a100 8301 5a26 6527 6526 8301 4400 9002 5d9e 5a28 650d 641d 6528 640d 1700 8302 0100 6524 651e a025 a100 8301 5a29 641e 640c 8400 6527 6529 8301 4400 8301 5a2a 6524 651e a025 a100 8301 5a2b 6527 652b 8301 4400 9002 5d54 5a2c 651e a025 a100 a02d a100 5a2e 6522 a025 a100 a02d a100 5a2f 6523 6520 6b06 9002 7270 652f 641f 6b03 9004 7230 650d 6420 8301 0100 650d 641d 6528 640d 1700 8302 0100 650d 6421 652c 640d 1700 8302 0100 650d 6422 8301 0100 650d 6423 652f 8302 0100 650d 6424 6523 1600 8301 0100 6501 a00e a100 0100 9001 6ec0 652e a030 a100 5a31 652f a030 a100 5a32 6532 4400 5d5c 5a33 6533 652a 6b07 9002 7284 650d 6420 8301 0100 650d 641d 6528 640d 1700 8302 0100 650d 6421 652c 640d 1700 8302 0100 650d 6423 652f 8302 0100 650d 6425 6533 8302 0100 650d 6424 6523 1600 8301 0100 6501 a00e a100 0100 9002 7184 6426 640c 8400 6531 4400 8301 5a34 6427 640c 8400 6532 4400 8301 5a35 6534 6535 6b03 9003 725c 650d 6420 8301 0100 650d 641d 6528 640d 1700 8302 0100 650d 6421 652c 640d 1700 8302 0100 650d 6428 652e 8302 0100 650d 6423 652f 8302 0100 650d 6429 8301 0100 650d 6424 6523 1600 8301 0100 6501 a00e a100 0100 652e a036 642a 642b a102 5a37 652f a036 642a 642b a102 5a38 6900 5a39 653a 6537 8301 4400 5dae 5c02 5a3b 5a3c 6538 653b 1900 5a3d 653c 6539 6b06 9003 6fa4 6539 653c 1900 653d 6b03 5a3e 653d 6539 6b06 9003 6fba 6539 653d 1900 653c 6b03 5a3f 653e 9003 73c8 653f 9004 721c 650d 6420 8301 0100 650d 641d 6528 640d 1700 8302 0100 650d 6421 652c 640d 1700 8302 0100 650d 6428 652e 8302 0100 650d 6423 652f 8302 0100 650d 642c 8301 0100 650d 6424 6523 1600 8301 0100 6501 a00e a100 0100 653d 6539 653c 3c00 653c 6539 653d 3c00 9003 7180 6523 640d 3700 5a23 650d 642d 652c 1600 8301 0100 9001 71f0 9001 71aa 651e a021 a100 0100 6522 a021 a100 0100 6ebe 651d 6519 8301 5a1e 651e a01f a100 5a40 651e a021 a100 0100 651d 651a 8301 5a1e 651e a01f a100 5a41 651e a021 a100 0100 6511 6540 8301 5a26 653a 6540 8301 4400 5d7c 5c02 5a3b 5a42 6541 653b 1900 a02d a100 5a43 6542 a02d a100 5a42 6543 6542 6b03 9005 7204 650d 6420 8301 0100 650d 642e 653b 640d 1700 8302 0100 650d 642f 6542 8302 0100 650d 6423 6543 8302 0100 650d 6424 653b 1600 8301 0100 6501 a00e a100 0100 6e14 650d 6430 653b 640d 1700 6526 6602 1600 8301 0100 9004 719e 650d 6431 8301 0100 6502 a002 a100 5a44 650d 6432 6544 6517 1800 1600 8301 0100 6401 5300 2933 e900 0000 004e 2901 da08 6461 7465 7469 6d65 69e5 0700 00e9 0300 0000 e906 0000 005a 0673 6f6c 656e 6e5a 0667 7261 6465 735a 066d 696e 696f 6e5a 0764 6563 7279 7074 7a28 596f 7520 6172 6520 6e6f 7420 616c 6c6f 7765 6420 746f 2075 7365 2074 6869 7320 6368 6563 6b65 722e 6301 0000 0000 0000 0000 0000 0002 0000 0004 0000 0043 0000 0073 1800 0000 6700 7c00 5d10 7d01 7c01 a000 a100 a001 a100 9102 7104 5300 a900 2902 da05 6c6f 7765 72da 0573 7472 6970 a902 da02 2e30 da01 7872 0500 0000 7205 0000 00fa 1f44 3a5c 434d 5343 5c31 3432 5c6c 6162 5c6c 6162 315c 6368 6563 6b65 722e 7079 da0a 3c6c 6973 7463 6f6d 703e 1000 0000 7304 0000 0006 0002 0072 0c00 0000 e901 0000 007a 2355 7361 6765 3a20 7079 7468 6f6e 2063 6865 636b 6572 2e70 7963 203c 7072 6f62 6c65 6d3e 7a0a 3c70 726f 626c 656d 3e3a 7a02 2c20 7a05 2573 2e70 797a 1545 7272 6f72 3a20 4361 6e6e 6f74 2066 696e 6420 2573 7a08 5052 4f42 4c45 4d3a 7a0d 6461 7461 2f69 6e70 7574 5f25 737a 1064 6174 612f 736f 6c75 7469 6f6e 5f25 737a 0e64 6174 612f 6f75 7470 7574 5f25 737a 183e 3e3e 2052 756e 6e69 6e67 2079 6f75 7220 636f 6465 2e2e 2e7a 0770 7974 686f 6e20 7a03 203c 207a 0320 3e20 7a1b 3e3e 3e20 4368 6563 6b69 6e67 2079 6f75 7220 616e 7377 6572 732e 2e63 0100 0000 0000 0000 0000 0000 0200 0000 0400 0000 4300 0000 7314 0000 0067 007c 005d 0c7d 0174 007c 0183 0191 0271 0453 0072 0500 0000 2901 da03 696e 7472 0800 0000 7205 0000 0072 0500 0000 720b 0000 0072 0c00 0000 2c00 0000 7304 0000 0006 0002 007a 0b54 6573 7420 4361 7365 2023 6301 0000 0000 0000 0000 0000 0002 0000 0004 0000 0043 0000 0073 1800 0000 6700 7c00 5d10 7d01 7400 a001 a100 a002 a100 9102 7104 5300 7205 0000 0029 03da 0166 da08 7265 6164 6c69 6e65 7207 0000 0029 0272 0900 0000 da01 7772 0500 0000 7205 0000 0072 0b00 0000 720c 0000 0037 0000 0073 0400 0000 0600 0200 5a04 4e4f 4e45 7a1b 4f6f 7073 2120 536f 6d65 7468 696e 6720 6973 2077 726f 6e67 203a 287a 094d 6573 7361 6765 2023 7a14 436f 7272 6563 7420 416e 7377 6572 3a20 4e4f 4e45 7a0c 596f 7572 2041 6e73 7765 723a 7a2d 476f 7420 2564 2074 6573 7420 6361 7365 7320 616e 7377 6572 6564 2063 6f72 7265 6374 6c79 2073 6f20 6661 722e 2e7a 1945 5252 4f52 3a20 4e6f 7420 696e 2076 6f63 6162 756c 6172 793a 6301 0000 0000 0000 0000 0000 0002 0000 0004 0000 0043 0000 0073 1400 0000 6700 7c00 5d0c 7d01 7400 7c01 8301 9102 7104 5300 7205 0000 00a9 01da 036c 656e 7208 0000 0072 0500 0000 7205 0000 0072 0b00 0000 720c 0000 0057 0000 0073 0400 0000 0600 0200 6301 0000 0000 0000 0000 0000 0002 0000 0004 0000 0043 0000 0073 1400 0000 6700 7c00 5d0c 7d01 7400 7c01 8301 9102 7104 5300 7205 0000 0072 1200 0000 7208 0000 0072 0500 0000 7205 0000 0072 0b00 0000 720c 0000 0058 0000 0073 0400 0000 0600 0200 7a08 4d65 7373 6167 653a 7a1e 4552 524f 523a 2057 6f72 6420 6c65 6e67 7468 7320 646f 6e74 206d 6174 6368 fa01 20da 007a 1a45 5252 4f52 3a20 496e 7661 6c69 6420 7472 616e 736c 6174 696f 6e7a 1109 204d 6573 7361 6765 2023 2564 2e2e 4f4b 7a0b 5465 7374 2063 6173 6520 237a 0f43 6f72 7265 6374 2041 6e73 7765 723a 7a0b 2564 202f 2025 642e 2e4f 4b7a 2441 4c4c 2054 4553 5420 4341 5345 5320 414e 5357 4552 4544 2043 4f52 5245 4354 4c59 203a 297a 0954 696d 653a 2025 6473 2945 da02 6f73 da03 7379 73da 0474 696d 6572 0200 0000 5a0c 4355 5252 454e 545f 5945 4152 5a0b 4d4f 4e54 485f 5354 4152 545a 094d 4f4e 5448 5f45 4e44 5a0e 7661 6c69 645f 7072 6f62 6c65 6d73 5a03 6e6f 775a 0479 6561 725a 0779 6561 725f 6f6b 5a05 6d6f 6e74 685a 086d 6f6e 7468 5f6f 6bda 0570 7269 6e74 da04 6578 6974 da04 6172 6776 da04 6172 6773 7213 0000 00da 046a 6f69 6e5a 0770 726f 626c 656d da08 6669 6c65 6e61 6d65 da04 7061 7468 da06 6578 6973 7473 da05 7374 6172 745a 0974 6573 745f 6e61 6d65 5a0d 736f 6c75 7469 6f6e 5f6e 616d 655a 0b6f 7574 7075 745f 6e61 6d65 5a07 636f 6d6d 616e 64da 0673 7973 7465 6dda 046f 7065 6e72 0f00 0000 da09 7265 6164 6c69 6e65 735a 0a6e 6f5f 616e 7377 6572 73da 0563 6c6f 7365 5a0b 616e 7377 6572 5f66 696c 655a 0a61 6e73 7765 725f 6964 7872 0e00 0000 7210 0000 005a 0e6e 756d 5f74 6573 745f 6361 7365 73da 0572 616e 6765 da01 745a 096e 756d 5f77 6f72 6473 5a05 776f 7264 735a 0d6e 756d 5f65 6e63 7279 7074 6564 da01 6572 0700 0000 5a07 656e 635f 6d73 675a 0764 6563 5f6d 7367 da05 7370 6c69 745a 0965 6e63 5f77 6f72 6473 5a09 6465 635f 776f 7264 735a 0864 6563 5f77 6f72 645a 0f65 6e63 5f6c 656e 5f70 6174 7465 726e 5a0f 6465 635f 6c65 6e5f 7061 7474 6572 6eda 0772 6570 6c61 6365 5a08 656e 635f 6c6f 6e67 5a08 6465 635f 6c6f 6e67 da07 6d61 7070 696e 67da 0965 6e75 6d65 7261 7465 da01 695a 076c 6574 7465 7231 5a07 6c65 7474 6572 325a 0665 7272 6f72 315a 0665 7272 6f72 325a 0873 6f6c 7574 696f 6e5a 0661 6e73 7765 725a 0373 6f6c 5a03 616e 73da 0365 6e64 7205 0000 0072 0500 0000 7205 0000 0072 0b00 0000 da08 3c6d 6f64 756c 653e 0100 0000 73f0 0000 0018 010c 0204 0104 0104 010c 0208 010a 0114 0108 0108 0108 0218 0118 0108 0110 0108 0208 0108 010c 010c 0108 0208 010a 0208 0108 0108 0208 0118 010a 0308 020a 0108 0112 0108 0208 0108 0204 010c 010e 010e 010c 0112 020c 010e 010c 010c 020a 020a 0108 010e 010e 0108 010a 010c 010c 0308 0108 0208 010a 0108 010e 010e 010a 010a 010c 010c 020e 010e 010a 0108 010e 010e 010a 010a 0108 010c 0108 020c 010c 0104 0110 0108 0216 0116 010c 0108 010e 010e 010a 010a 0108 010c 0108 0208 010c 0208 0114 0308 010a 0208 0108 0108 0208 0108 0108 0208 0110 010c 0108 010a 0108 010e 010a 010a 010c 010a 0218 0208 0208 01

PROBLEM 3: Minion Language 10 points You love the Minions! Who doesn't? After several weeks of studying their language, you have learned all of the words in Minionese. You noticed that each word in this language is exactly of length L, for some number L, The Despicable Me movie producers have decided to create a movie starring the Minions. But they want the movie's script to be written in Minionese (it's more authentic that way, they said). The producers heard about your work with the Minion language and decided to hire you to work on the movie's subtitles. During the production of the movie, however, you encountered some problems. There are some words in the movie's audio that are inaudible. You figured that context clues might help translate the word, but you can only do that if you have all the possible translations the inaudible word. Example: The line is "eoui *inaudible* nana", and the inaudible word seemed like it started with "w" and ended in nt", but you're unsure if the middle part was an a or o", so you write this notation: (ao)nt". Since this is not part of your job (figuring out what each word might be), you asked for a raise in your salary, and the movie producers agreed to pay you P10 per unclear word. For you to get your additional pay, you were asked to create an algorithm that counts the number of possible interpretations of an inaudible word. INPUT You will be reading input from the command line. The first input is the number of versions of the Minion language you are going to work on, say M. This is followed by M chunks of data, formatted as follows: Next input contains 2 numbers separated by a space: LD o Lis the length of each word in the language o Dis the number of words in the language This is followed by D lines, each containing a word (of length L) in the language Next input is the number of inaudible word pattems you have to solve, say P After that, P lines follow, each containing the pattem of the inaudible word OUTPUT For each inaudible word pattem, output the number of words in the language that match the pattern. EXAMPLE INPUT EXPECTED OUTPUT 3 28 ba na bo bi la ta to 5 (bd) b(aeiou) (ptd) (bnt)(ao) (xyz) EXPLANATION 1: ba only; da not in language 3: ba, bo, bi only; be, bu not in language 2: po, to only, do not in language 5: ba, bo, na, ta, to only, no not in language 0: xa, ya, za not in language PROBLEM 3: Minion Language 10 points You love the Minions! Who doesn't? After several weeks of studying their language, you have learned all of the words in Minionese. You noticed that each word in this language is exactly of length L, for some number L, The Despicable Me movie producers have decided to create a movie starring the Minions. But they want the movie's script to be written in Minionese (it's more authentic that way, they said). The producers heard about your work with the Minion language and decided to hire you to work on the movie's subtitles. During the production of the movie, however, you encountered some problems. There are some words in the movie's audio that are inaudible. You figured that context clues might help translate the word, but you can only do that if you have all the possible translations the inaudible word. Example: The line is "eoui *inaudible* nana", and the inaudible word seemed like it started with "w" and ended in nt", but you're unsure if the middle part was an a or o", so you write this notation: (ao)nt". Since this is not part of your job (figuring out what each word might be), you asked for a raise in your salary, and the movie producers agreed to pay you P10 per unclear word. For you to get your additional pay, you were asked to create an algorithm that counts the number of possible interpretations of an inaudible word. INPUT You will be reading input from the command line. The first input is the number of versions of the Minion language you are going to work on, say M. This is followed by M chunks of data, formatted as follows: Next input contains 2 numbers separated by a space: LD o Lis the length of each word in the language o Dis the number of words in the language This is followed by D lines, each containing a word (of length L) in the language Next input is the number of inaudible word pattems you have to solve, say P After that, P lines follow, each containing the pattem of the inaudible word OUTPUT For each inaudible word pattem, output the number of words in the language that match the pattern. EXAMPLE INPUT EXPECTED OUTPUT 3 28 ba na bo bi la ta to 5 (bd) b(aeiou) (ptd) (bnt)(ao) (xyz) EXPLANATION 1: ba only; da not in language 3: ba, bo, bi only; be, bu not in language 2: po, to only, do not in language 5: ba, bo, na, ta, to only, no not in language 0: xa, ya, za not in language

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Accounting questions