CF54D.Writing a Song

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

One of the Hedgehog and his friend's favorite entertainments is to take some sentence or a song and replace half of the words (sometimes even all of them) with each other's names.

The friend's birthday is approaching and the Hedgehog decided to make a special present to his friend: a very long song, where his name will be repeated many times. But try as he might, he can't write a decent song!

The problem is that the Hedgehog has already decided how long the resulting sentence should be (i.e. how many letters it should contain) and in which positions in the sentence the friend's name should occur, and it must not occur in any other position in the sentence. Besides, the Hedgehog decided to limit himself to using only the first KK letters of an English alphabet in this sentence (so it will be not even a sentence, but one long word).

The resulting problem is indeed quite complicated, that's why the Hedgehog asks you to help him and write a program that will make the desired word by the given name PP , the length NN of the required word, the given positions of the occurrences of the name PP in the desired word and the alphabet's size KK . Note that the occurrences of the name can overlap with each other.

输入格式

The first line contains numbers NN and KK which are the length of the required string and the alphabet size accordingly. The limitations are: 1<=N<=1001<=N<=100 , 2<=K<=262<=K<=26 .

The second line contains the name PP which is a non-empty string whose length does not exceed NN characters. The string consists only of the first KK lowercase symbols of an English alphabet.

The third line contains the string of length Nlength(P)+1N-length(P)+1 , consisting only of numbers zero and one. A number one in the ii -th position means that an occurrence of the name PP should start from ii -th position of the desired word, while a zero means that there is no occurrence starting here.

输出格式

Print the desired word SS . If there are several answers, print any of them.

If there is no solution, then print "No solution".

输入输出样例

  • 输入#1

    5 2
    aba
    101
    

    输出#1

    ababa
  • 输入#2

    5 2
    a
    10001
    

    输出#2

    abbba
  • 输入#3

    6 2
    abba
    101
    

    输出#3

    No solution
首页