Problem: Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.    * Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').

Submission attempts (in order):
s=input()
t=input()

slist=list(s)
tlist=list(t)

slist.append("aa")
scounter=0

for tchar in tlist:
  for schar in slist:
    
    if schar =="aa":
      scounter=-1
      break
    if tchar==schar:
      break
    scounter+=1
    
  if scounter==-1:
    break
    
print(scounter)


while endflag==False:
  if 
  





slist = input()
tlist = input()
scounter = 0
slength=len(slist)
slist=slist+slist
preposition=-1
for tchar in tlist:
    preposition=slist.find(tchar, preposition+1)
    if preposition==-1:
        scounter=-1
        break
    elif preposition>slength:
        scounter+=slength
        preposition-=slength
    print(tchar, scounter, preposition)
if (scounter==-1):
    print(scounter)
else:
    print(scounter+preposition+1)

s = input()
t = input()

slist = list(s)
tlist = list(t)


scounter = 0
slength=len(slist)

for tchar in tlist:
    tcharcheckflag=False
    Slist=[]
    for schar in slist[scounter%slength:]:
        Slist.append(schar)
    for schar in slist[:scounter%slength]:
        Slist.append(schar)
    Slist.append("aa")
    for schar in Slist:
        print(schar,tchar,scounter)
        if schar == "aa":
            scounter = -1
            tcharcheckflag=True
            break
        if tchar == schar:
            scounter += 1
            tcharcheckflag=True
            break
        scounter+=1
    if scounter == -1:
        break

print(scounter)

s = input()
t = input()

slist = list(s)
tlist = list(t)

slist.append("aa")
scounter = 0
slength=len(slist)

for tchar in tlist:
    tcharcheckflag=False
    for schar in slist[scounter%slength:]:
        
        if schar == "aa":
            scounter = -1
            tcharcheckflag=True
            break
        if tchar == schar:
            scounter += 1
            tcharcheckflag=True
            break
    if tcharcheckflag==False:
        for schar in slist[:scounter%slength]:
            print(schar, tchar, scounter)
            if schar == "aa":
                scounter = -1
                tcharcheckflag = True
                break
            if tchar == schar:
                scounter += 1
                tcharcheckflag = True
                break


    if scounter == -1:
        break

print(scounter)

s=input()
t=input()
 
slist=list(s)
tlist=list(t)

slist.append("aa")
scounter=0
 
for tchar in tlist:
  for schar in slist:
    
    if schar =="aa":
      scounter=-1
      break
    if tchar==schar:
      break
    scounter+=1
    
  if scounter==-1:
    break
    
print(scounter)

slist = input()
tlist = input()
scounter = 0
slength=len(slist)
for tchar in tlist:
    Sstart=scounter%slength
    while True:
        print(tchar,slist[scounter%slength],scounter)
        if tchar == slist[scounter%slength]:
            scounter += 1
            break
        scounter += 1
        if scounter%slength==Sstart:
            scounter=-1
            break
    if scounter==-1:
        break
print(scounter)

slist = input()
tlist = input()
scounter = 0
slength=len(slist)
slist=slist+slist
preposition=-1
for tchar in tlist:
    preposition=slist.find(tchar, preposition+1)
    if preposition==-1:
        scounter=-1
        break
    elif preposition>=slength:
        scounter+=slength
        preposition-=slength
    
if (scounter==-1):
    print(scounter)
else:
    print(scounter+preposition+1)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted