Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Sattwik

Автор Sattwik, история, 2 года назад, По-английски

**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]

######

**

  • Проголосовать: нравится
  • -18
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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]

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    2 года назад, # ^ |
    Rev. 3   Проголосовать: нравится -8 Проголосовать: не нравится

    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).

    • »
      »
      »
      2 года назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

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

    • »
      »
      »
      2 года назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

      • »
        »
        »
        »
        2 года назад, # ^ |
        Rev. 3   Проголосовать: нравится -8 Проголосовать: не нравится

        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

        • »
          »
          »
          »
          »
          2 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

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

          • »
            »
            »
            »
            »
            »
            2 года назад, # ^ |
              Проголосовать: нравится 0 Проголосовать: не нравится

            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