Sattwik's blog

By Sattwik, history, 3 years ago, In English

**INITIALLY YOU ARE GIVEN TWO STRINGS S AND T OF LOWER CASE LATIN WORDS. YOU CAN REPLACE ANY CHARACTER OF S WITH STRING T,ANY NUMBER OF TIMES . YOU APPLY THE SAME PROCEDURE ON THE NEW STRING FORMED BY REPLACING A CHARACTER . LET S=s1,s2,s3,s4...sn (si is the ith character) and T = "ab". THEN YOU CHANGE s1-->T . HENCE new string becomes ab,s2,s3,s4...sn. Now you can further change any character of this new string with T . NOW YOU HAVE TO FIND THE TOTAL NUMBER OF UNIQUE STRINGS YOU CAN CREATE BY DOING THE ABOVE PROCESS ANY NUMBER OF TIMES(POSSIBLY ZERO).

SOME EXAMPLES :

S="abc" T ="dk" output =-1 since [dkbc,ddkbc,ddkbdc,.....infinte newstrings can be created] s="abc" T="x" output =8 since[abc,abx,axb,xbc,axx,xxc,xbx,xxx] s="aab" T="ab" output=-1 since[aaab,aaaab,.....infinite new strings can be created] s="ab" T="d" output=4 since[ab,ad,bd,dd]

######

**

  • Vote: I like it
  • -18
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Whenever |T| > 1, the answer should be infinite, and if |T| = 1, its 2^k, where k is number of positions where T[0] != S[i]

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    yes correct ...thank you for replying my vlog ...can you kindly rate this question according to codeforce rating ? is it above 800 ?

  • »
    »
    3 years ago, # ^ |
    Rev. 3   Vote: I like it -8 Vote: I do not like it

    If |T| > 1 and if it has at least 1 letter 'a': only then it is infinite, otherwise (if |T| > 1 and it doesnt contain any 'a') we apply 2^n operation (where n in my code denotes number of 'a' in S).

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      brother i have framed a different question ... see some changes

    • »
      »
      »
      3 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      that is not true, what ever T (|T| > 1) is you can add it any number of times

      • »
        »
        »
        »
        3 years ago, # ^ |
        Rev. 3   Vote: I like it -8 Vote: I do not like it

        1st case: s = 'aabaad', t = 'bcd' -- here you have only 2^4 = 16 possible strings. 2nd case: s = 'aabaad', t = 'bad' -- whereas here the number of unique strings is infinite

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Now I am actually regretting this conversation, anyway, please read the question in this blog.

          • »
            »
            »
            »
            »
            »
            3 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Well my mind was probably taken away by the recent similar question and therefore i barely can get the logic of this problem. Everything what i said was related to the problem int the contest. Sorry for throwing some random stuff, my bad guys