21672_WordGame

2022-5-16 18:20| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505747181799-Problem List-采集的数据-后羿采集器.html

Pro.ID

21672

Title

Word Game

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21672

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    It's a game with two players. Given a dictionary of words, a word S chosen from the dictionary to start with, and a word T also chosen from the dictionary as the winning word, which will be described below, the two players take turns to choose a word from the dictionary, satisfying that the first letter of the chosen word is the same as the last letter of previous word. Each word could be chosen more than once.

    Suppose they play exactly n rounds. At the last round, if the player (the first one if n is odd, the second one otherwise) chooses the winning word T, he wins. To your surprise that, the two players are not so clever that they choose words randomly.

    Here comes the question. How many different ways will the first player win if they play no more than N rounds, among all the possible ways satisfying all the conditions above?

    输入

    An integer C, indicates the number of test cases.

    Then comes C blocks, formatted like this:

    An integer M, indicates the number of words in the dictionary, M ≤ 30.

    M string consisting of only lowercase letters, represent the words in the dictionary. The length of each word is no more than 10. There are no duplicated words.

    String S, the word to start with.

    String T, the winning word.

    A positive integer N, indicates the maximum number of rounds to play. N fits in a signed 32-bit integer.

    输出

    Description

    It's a game with two players. Given a dictionary of words, a word S chosen from the dictionary to start with, and a word T also chosen from the dictionary as the winning word, which will be described below, the two players take turns to choose a word from the dictionary, satisfying that the first letter of the chosen word is the same as the last letter of previous word. Each word could be chosen more than once.

    Suppose they play exactly n rounds. At the last round, if the player (the first one if n is odd, the second one otherwise) chooses the winning word T, he wins. To your surprise that, the two players are not so clever that they choose words randomly.

    Here comes the question. How many different ways will the first player win if they play no more than N rounds, among all the possible ways satisfying all the conditions above?

    Input

    An integer C, indicates the number of test cases.

    Then comes C blocks, formatted like this:

    An integer M, indicates the number of words in the dictionary, M ≤ 30.

    M string consisting of only lowercase letters, represent the words in the dictionary. The length of each word is no more than 10. There are no duplicated words.

    String S, the word to start with.

    String T, the winning word.

    A positive integer N, indicates the maximum number of rounds to play. N fits in a signed 32-bit integer.

    Output

    For each test case, print a line with an integer W, indicating how many possible ways the first player wins.

    Output the answer modulo 10001.

    Sample Input

    1
    3
    abc
    cac
    cde
    abc
    cde
    3

    Sample Output

    2

    Source

    样例输入

    1
    3
    abc
    cac
    cde
    abc
    cde
    3

    样例输出

    2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部