Problem:


Score: 400 points

Problem Statement

AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.

The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.

How many different PIN codes can he set this way?

Both the lucky number and the PIN code may begin with a 0.

Constraints

4 \leq N \leq 30000

S is a string of length N consisting of digits.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of different PIN codes Takahashi can set.

Sample Input 1

4
0224

Sample Output 1

3

Takahashi has the following options:

Erase the first digit of S and set 224.

Erase the second digit of S and set 024.

Erase the third digit of S and set 024.

Erase the fourth digit of S and set 022.

Thus, he can set three different PIN codes: 022, 024, and 224.

Sample Input 2

6
123123

Sample Output 2

17

Sample Input 3

19
3141592653589793238

Sample Output 3

329



Sample input:
4
0224


Sample output:
3

Submission status: Wrong Answer

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator

def firstnum(s):
    n = len(s)
    res = [[-1]*10 for _ in range(n+1)]
    for i in range(n-1, -1, -1):
        for j in range(10):
            res[i][j] = res[i+1][j]
            res[i][int(s[i])] = i
    return res

def solve():
    n = int(input())
    s = input()
    next = firstnum(s)
    dp = [[-1]*4 for _ in range(n+1)]
    for i in next:
        print(i)
    dp[0][0] = 1
    for i in range(n):
        for k in range(3):
            for j in range(10):
                if next[i][j] == -1:
                    continue
                dp[next[i][j]+1][k+1] += dp[i][k]
    sushi = 0
    for i in dp:
        sushi += i[3]
    print(sushi)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[int(x) for x in list(input())]
m=[[] for i in range(10)]
for i in range(n):
  m[s[i]].append(i)
ans=0
res=[]
for a in range(10):
  for b in range(10):
    for c in range(10):
      if a==b==c:
        if len(m[a])>= 3:
          ans+=1
      elif a==b:
        if len(m[a])< 2 or len(m[c])<1:
          continue
        if any([x>m[b][1] for x in m[c]]):
          ans+=1
      elif b==c:
        if len(m[b])<2 or len(m[a])<1:
          continue
        if any([x>m[a][0] for x in m[c][1:]]):
          ans+=1
      elif c==a:
        if len(m[a])<2 or len(m[b])<1:
          continue
        if any([x>m[a][0] for x in m[b]]) and any([x<m[c][1] for x in m[b]]):
          ans += 1
      else:
        if len(m[a])*len(m[b])*len(m[c])==0:
          continue
        tmp = [x>m[a][0] for x in m[b]]
        if any(tmp) and any([x>tmp[0] for x in m[c]]):
          ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[int(x) for x in list(input())]
m=[[] for i in range(10)]
for i in range(n):
  m[s[i]].append(i)
ans=0
for a in range(10):
  if len(m[a]) == 0:
    continue
  for b in range(10):
    if len(m[b])==0:
      continue
    for c in range(10):
      if len(m[c])==0:
        continue
      if any([x>m[a][0] for x in m[b]]) and any([x>m[b][a==b] for x in m[c]]):
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]


n = int(input())
s = input()
ans = 0

for i in range(0,1000):
    num = str(i)
    if i < 10:
        num = "00"+num
    elif i <100:
        num = "0" + num
    for j in range(n):
        if s[j] == num[0]:
            for k in range(j+1,n):
                if s[k] == num[1]:
                    for l in range(k+1,n):
                        if s[l] == num[2]:
                            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans,a=0,[]
for i in range(n):
    if s[i] not in a:
        a+=[s[i]]
        b=[]
        for j in range(i+1,n):
            if s[j] not in b:
                b+=[s[j]]
                c=[]
                for k in range(j+1,n):
                    if k not in c:
                        c+=[s[k]]
                        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
d={}
ans=0
for x in range(n-2):
  if s[x] not in d:
    d[s[x]]=0
    for y in range(x+1,n-1):
      if int(s[x]+s[y]) not in d:
        d[int(s[x]+s[y])]=0
        for z in range(y+1,n):
          if int(s[x]+s[y]+s[z]) not in d:
            d[int(s[x]+s[y]+s[z])]=0
            ans+=1
    
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
n=len(s)
ans=0
for i in range(0,10):
  for x in range(0,n-2):
    if s[x]==str(i):
      for j in range(0,10):
        for y in range(x+1,n-1):
          if s[y]==str(j):
            for k in range(0,10):
              for z in range(y+1,n):
                if s[z]==str(k):
                  ans+=1
                  
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    S=list(input())

    ans = 0
    for i in range(1,1000):
        pin = str(i)
        if len(pin) == 1:
            pin = "00"+pin
        elif len(pin) == 2:
            pin = "0"+pin
        
        waiti = 0
        for j in range(N):
            if S[j] == pin[waiti]:
                waiti += 1
                if waiti == 3:
                    break
                    
        if waiti == 3:
            ans += 1

    print(ans)
            
            





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()

pin=set()

for i in range(N):
    for j in range(i+1,N):
        for k in range(i+j+1,N):
            pin.add(str(S[i])+str(S[j])+str(S[k]))
            # print((str(S[i])+str(S[j])+str(S[k])))

# print(pin)
print(len(pin))

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    S = input()
    Si = list(S)
    ans = 0
    for i in range(10):
        for j in range(10):
            for p in range(10):
                if S.count(str(i)) >= 1 and S.count(str(j)) >= 1 and S.count(str(p)) >= 1 and Si.index(str(i)) < Si.index(str(j)) < Si.index(str(p)):
                     ans += 1
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()

score = 0

for p in range(1000):
    
    pw = str(p).zfill(3)
    
    start = 0
    n_match = 0
    
    for j in range(3):
        for i in range(start, len(s)):
            
            if s[i] == pw[j]:
                start = i+1
                n_match = n_match+1
                
                if j == 3-1:
                    print(pw)
                    score = score+1
                
                break
        if n_match <= j:
            break
            
print(score)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()

passwords =[]

a_log=[]
ab_log=[]

for a in range(n-2):
    
    is_a_kaburi = 0
    
    for i in a_log:
        
        if i == a:
            is_a_kaburi = 1
            
    if is_a_kaburi == 0:
        
        a_log.append(a)
        
        for b in range(a+1,n-1):
            
            is_ab_kaburi = 0
            
            for i in ab_log:
                
                if i == a+b:
                    is_ab_kaburi = 1
                    
            if is_ab_kaburi == 0:
                
                ab_log.append(a+b)
    
                for c in range(b+1,n):
                    
                    pw = s[a] + s[b] + s[c] 
                    passwords.append(pw)
                    # passwords = list(set(passwords))
                    
                    # print(pw)

print(len(passwords))

Submission status: Wrong Answer

Solution code:
"""
全探索
左から文字を1個ずつ取っていく
かぶりをなくすために一回リストに格納した後セットにする
これではTLE
passwordは0~999なのでそれがsに入っているかで判定
"""
n = int(input())
s = input()
ans = 0
for password in range(0,1000) :
    if len(str(password)) < 3 :
        password = "0" * (3-len(str(password))) + str(password)
    if str(password) in s :
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
flg = [0 for i in range(1000)]
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(10):
            if str(k) in s[j + 1:]:
                flg[int(s[i] + s[j] + str(k))] = 1
print(flg)
print(flg.count(1))

Submission status: Wrong Answer

Solution code:

N=int(input())
S=list(input())
numlist=range(1000)
ans=0

for i in numlist:
    num=str(i)
    if len(num)==1:
        num="00"+num
    if len(num)==2:
        num="0"+num
    if num[0] in S[:N-1]:
        num1=S.index(num[0])
        if num[1] in S[num1+1:N-1]:
            S2=S[num1+1:N-1]
            num2=S2.index(num[1])+num1+1
            if num[2] in S[num2+1:]:
                ans+=1
                print(i)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
S = input()
S_list = [S[i] for i in range(N)]
S_c = collections.Counter(S_list)
list12 = []
list1 = []

ans = 0
for i in range(N-2):
    s1 = S_list[i]
    S_c[s1] = S_c[s1]-1
    S_c23 = S_c.copy()
    list1.append(s1)
    
    if s1 in list1:
        continue
        
    for j in range(i+1,N-1):
        s2 = S_list[j]

        S_c23[s2] = S_c23[s2] - 1
        if (s1+s2) in list12:
            continue
        else:
            list12.append(s1+s2)
            for key in S_c23.keys():
                if S_c23[key] != 0:
                    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans=0
for i in range(10):
  a=s.find(str(i))
  if a == -1:
    continue
  for j in range(10):
    b=s.find(str(j),a)
    if b == -1:
      continue
    for k in range(10):
      if s.find(str(k),b) != -1:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans=0
for i in range(10):
  a=s.find(str(i))
  if a == -1:
    continue
  for j in range(10):
    b=s.find(str(j),a)
    if b == -1:
      continue
    for k in range(10):
      if s.find(str(k)) != -1:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import copy
input = sys.stdin.readline

N=int(input())

S=input()


T=[[0] * 10 for _ in range(30000)]
for i in range(N):
    if i!=0:
        T[i]=copy.deepcopy(T[i-1])
    T[i][int(S[i])]+=1
#print(T)

dic={}
flag=[False]*10
for i in range(N-2):
    if flag[int(S[i])]==True:
        continue
    flag[int(S[i])]=True
    for j in range(i+1,N-1):
        tmp2=copy.deepcopy(T[N-1])
        tmp3=copy.deepcopy(T[j])
        tmp4=""
        for k in range(10):
            if tmp2[k]-tmp3[k]!=0:
                tmp4=S[i]+S[j]+str(k)
            if tmp4 in dic:
                pass
            else:    
                dic[tmp4]=1
                
print(len(dic)-1)

Submission status: Wrong Answer

Solution code:
import sys
import copy
input = sys.stdin.readline

N=int(input())

S=input()


T=[[0] * 10 for _ in range(30000)]
for i in range(N):
    if i!=0:
        T[i]=copy.deepcopy(T[i-1])
    T[i][int(S[i])]+=1
print(T)
'''
dic={}
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp=copy.deepcopy(T[N-1])-copy.deepcopy(T[j])
        for k in range(10)
            if k!=0:
                
print(len(dic))
'''

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N=int(input())
S=input()
dic={}
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp=set(S[j+1:])
        for k in tmp:
            tmp=S[i]+S[j]+k
            dic[tmp]=1
print(len(dic))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, list(input())))

f = [0]*1000

for i in range(n-2):
    if all(f[100*s[i]:100*s[i]+100]) == 1:
        print('i_cont')
        continue
    for j in range(i+1, n-1):
        if all(f[100*s[i]+10*s[j]:100*s[i]+10*s[j]+10]) == 1:
            print('j_cont')
            continue
        for k in range(j+1, n):
            f[100*s[i]+10*s[j]+s[k]] = 1
cnt = 0
for i in f:
    if i == 1:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

ans = 0

for i1 in range(0, 10):
	i1 = str(i1)
	l1 = S.find(i1)
	if l1 >= 0:
		S1 = S[l1 + 1:N]
		for i2 in range(0, 10):
			i2 = str(i2)
			l2 = S1.find(i2)
			if l2 >= 0:
				S2 = S[l2 + 1:N]
				for i3 in range(0, 10):
					i3 = str(i3)
					l3 = S2.find(i3)
					if(l3 > 0):
						ans += 1
						break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

ans = 0

for i1 in range(0, 10):
	i1 = str(i1)
	l1 = S.find(i1)
	if l1 >= 0:
		for i2 in range(0, 10):
			i2 = str(i1)
			l2 = S[l1 + 1:N].find(i2)
			if l2 >= 0:
				for i3 in range(0, 10):
					i3 = str(i1)
					l3 = S[l2 + 1:N].find(i3)
					if(l3 > 0):
						ans += 1
						break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
n=int(input())
s=str(input())
ans_lis=[]
ans=0
for i in range(n-2):
    A=s[i]
    for j in range(i+1,n-1):
        B=s[j]
        for k in range(j+1,n):
            C=s[k]
            tmp=A+B+C
            if tmp in ans_lis:
                break
            else:
                ans_lis.append(tmp)
                ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
cnt=0
for m in range(1000):
  m=str(m).zfill(3)
  if m[0] not in s:continue
  i=s.index(m[0])+1
  if m[1] not in s[i:]:continue
  i=s[i:].index(m[1])+1
  if m[2] in s[i:]:cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
cnt=0
for m in range(1000):
  m=str(m).zfill(3)
  for i in range(n):
    if s[i]!=m[0]:continue
    for j in range(i+1,n):
      if s[j]!=m[1]:continue
      for k in range(j+1,n):
        if s[k]==m[2]:cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
ans = 0
for i in range(1,1000):
    t = str(i).zfill(3)
    for s in S:
        if s == t[0]:
            t = t[1:]
        if t == '':
            ans += 1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()

pin=[]*721
for p in range(N-2):
    for q in range(1,N-1):
        if p>=q:
            continue
        for r in range(2,N):
            if q>=r:
                continue
            n=int(S[p]+S[q]+S[r])
            if not n in pin:
                pin.append(n)
            if len(pin)==721:
                print(721)
                exit(0)
print(len(pin))

Submission status: Wrong Answer

Solution code:
19
3141592653589793238

Submission status: Wrong Answer

Solution code:
""" tutorial06
    https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d
"""
import sys
import math
from functools import reduce

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def main(N, S):
    """ main
    """
    count = 0
    skip1 = []
    skip2 = []
    skip3 = []

    for i in range(0, N):
        if S[i] in skip1:
            continue
        skip1.append(S[i])
        for j in range(i+1, N):
            if S[j] in skip2:
                continue
            skip2.append(S[j])
            for k in range(j+1, N):
                if S[k] in skip3:
                    continue
                skip3.append(S[k])
                print(S[i]+S[j]+S[k])
                count += 1
            skip3 = []
        skip2 = []

    return count

if __name__ == "__main__":
    _N = readInteger()
    _S = readString()

    print(main(_N, _S))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
count=0
for i in range(10):
    for j in range(N-2):
        if int(S[j])==i:
            for k in range(10):
                for l in range(j+1,N-1):
                    if int(S[l])==k:
                        for n in range(10):
                            for t in range(l+1,N):
                                if int(S[t])==n:
                                    count+=1
                                    break
                    break
print(count)

Submission status: Wrong Answer

Solution code:
def retindex(s, t, idx):
    for i in range(len(s)):
        if s[i] == t:
            return i+idx
    return -1

N = int(input())
S = input()
count = 0
for t1 in range(10):
    t1 = str(t1)
    idx1 = retindex(S[:-2], t1, 0)
    if idx1 == -1:
        continue
    else:
        for t2 in range(10):
            t2 = str(t2)
            idx2 = retindex(S[idx1+1:-1], t2, idx1)
            if idx2 == -1:
                continue
            else:
                for t3 in range(10):
                    if str(t3) in S[idx1+idx2+1:]:
                        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def resolve():
    n=int(input())
    s=list(input())
    chk=[0]*100
    l=[]
    ans=0
    for i in range(n-2):
        if chk[int(s[i])]==0:
            chk[int(s[i])]=1
            for j in range(i+1,n-1):
                x=s[i]+s[j]
                if chk[int(x)]==0:
                    chk[int(s[i])]=1
                    if x in l:
                        continue
                    else:
                        l.append(x)
                        ans+=len(set(s[j+1:]))
    print(ans)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
divide = 0
count = 0
for i in range(100,1000):
    num = str(i)
    flag = [0,0,0]
    for j in range(3):
        for k in range(divide,N):
            if num[j] == S[k]:
                flag[j] = 1
                divide = k+1
                break
    divide = 0      
    if(flag == [1,1,1]):
        count +=1
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
re_list=[]
ele = list(map(str, S))
v_list=[]
vi_list=[]
flag = 0
count = 0
for i in range(1000):
    if i < 10:
        v_list.append("00"+str(i+1))
    elif i < 100:
        v_list.append("0" + str(i + 1))
    else:
        v_list.append(str(i+1))

for i in range(1000):
    for j in range(N):
        if ele[j] == v_list[i][0] and flag == 0:
            flag = 1
            continue
        if ele[j] == v_list[i][1] and flag == 1:
            flag = 2
            continue
        if ele[j] == v_list[i][2] and flag == 2:
            count += 1
            break
    flag = 0
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

ans = 0

for i in range(10):
    a = S.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = S.find(str(j),a+1)
        for k in range(10):
            if b == -1:
                continue
            c = S.find(str(k),b+1)
            if c > b :
                ans +=1
                print(i,j,k)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input().zfill(n)

cnt = 0
for i in range(100,1000):
    N = str(i)
    #print(i)
    idx1,idx2 = 0,0
    bo1,bo2 = 0,0
    for j in range(n):
        if s[j] == N[0] and bo1 == 0:
            idx1 = j
            bo1 = 1
        elif s[j] == N[1] and bo1 == 1:
            idx2 = j
            bo2 = 1
        elif s[j] == N[2] and bo1 == 1 and bo2 == 1:
            cnt +=1
            #print(s[idx1],s[idx2],s[j])
            break
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = 0
for i in range(20):
    idx1 = s.find(str(i))
    for j in range(10):
        idx2 = s.find(str(j), idx1 + 1, n)
        for k in range(10):
            idx3 = s.find(str(k), idx2 + 1, n)
            if idx1 == -1 or idx2 == -1 or idx3 == -1:
                continue
            else:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,S = read().decode('utf-8').split()
print(N,S)
count = 0
for i in range(1000):
  s = str(i).zfill(3)
  index_all = 0
  for j in range(3):
    index = S[index_all:].find(s[j])
    if index == -1:
      break
    index_all += index+1
    if j ==2:
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
cou = 0
for i in range(1000):
  i = "{0:03d}".format(i)
  a,b,c = i[0],i[1],i[2]
  for j in range(n):
    if s[j]==a:
      for k in range(j+1,n):
        if s[k]==b:
          for m in range(k+1,n):
            if s[m]==c:
              cou += 1
              break
      break
print(cou)

Submission status: Wrong Answer

Solution code:
N=int(input())
word=set()
number=[]
S=list(map(int,input()))
for i in range(10):
    for j in range(10):
        for k in range(10):
           number.append([str(i)+str(j)+str(k)])
ans=0
for i in number:
    i,j,k=int(i[0][0]),int(i[0][1]),int(i[0][2])
    p1,p2,p3=-10,-1,-5
    for s in range(N):
        if S[s]==i and p1==-1:
            p1=s
        elif S[s]==j and p2<p1:
            p2=s
        elif S[s]==k and p3<p2:
            p3=s
            break
    if p1<p2<p3:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Jun  1 16:47:45 2020

@author: NEC-PCuser
"""

N = int(input())
S = input()
count = 0
for i in range(0, 999):
    j = 0
    a = str(i).zfill(3)
    for k in range(0, len(S)):
        if (a[j] == S[k]):
            j += 1
        if (j == 3):
            count += 1
            break
            
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
S=input()
l=[]
for i in range(26):
    num=str(i).zfill(3)
    s=S
    if s.find(num[0])==-1:
        continue
    s=s[s.index(num[0])+1:]
    if s.find(num[1])==-1:
        continue
    s=s[s.index(num[1])+1:]
    if s.find(num[2])==-1:
        continue
    l.append(num)
print(len(set(l)))

Submission status: Wrong Answer

Solution code:
_,m=open(0)
a=set(),set(),set(),{''}
for s in m:
 for b,c in zip(a,a[1:]):b|={t+s for t in c}
print(len(a[0]))

Submission status: Wrong Answer

Solution code:
_,j=open(0)
a=set(),set(),set(),{""}
for s in j:
 for b,c in zip(a,a[1:]):b|={t+s for t in c}
print(len(a[0]))

Submission status: Wrong Answer

Solution code:
import itertools
n = input()
s = input()
s = list(map(int, [i for i in s])) 
pin = set()
for i in itertools.permutations(s, 3):
  pin.add(i)
  
print(len(pin))

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
s=input()
p = itertools.combinations(range(n),3)
l=[]
for a,b,c in p:
    print(a,b,c)
    x=s[a]+s[b]+s[c]
    l.append(x)
print(len(set(l)))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
cnt = 0
for i in range(1000):
    p = '{:03}'.format(i)
    s2 = s
    for j in range(3):#indexのループ
        print(s2.find(p[j]))
        if s2.find(p[j]) == -1:
            break
        s2 = s2[s2.find(p[j]) +1:]
    else:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
cnt = 0
for i in range(100,1000):
    p = '{}'.format(i)
    s2 = s
    for j in range(3):#indexのループ
        if s2.find(p[j]) == -1:
            break
        s2 = s2[s2.find(p[j]) +1:]
    else:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n = II()
    S = list(map(int, list(input())))

    ans = 0
    for v in range(1, 1000):
        V = list(str(v))
        if len(V) == 2:
            V.insert(0, '0')
        elif len(V) == 1:
            V.insert(0, '0')
            V.insert(0, '0')
        # print(V)

        # end = [0] * 3
        cnt = 0
        for s in S:
            # print(V[cnt], str(s))
            if V[cnt] == str(s):
                cnt += 1
                if cnt == 3:
                    break
        # print(cnt)
        # input()
        if cnt == 3:
           ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import re

int(input())
s = input()
l = []
res = 0


def remove_ad(li):
    li2 = ""
    q = ""
    r = ""
    for p in str(li):
        if (p != q):
            li2 = li2 + p
        else:
            if (p != r): li2 = li2 + p
        r = q
        q = p
    return(li2)



t = remove_ad(s)
n = len(t)

for i in range(0,n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if(s[i]+s[j]+s[k] not in l):
                l.append(s[i]+s[j]+s[k])
                res += 1

print(res)

Submission status: Wrong Answer

Solution code:
s = input()
l = []
res = 0


def remove_ad(li):
    li2 = ""
    q = ""
    for p in str(li):
        if(p != q): li2 = li2 + p
        q = p
    return(li2)



t = remove_ad(s)
n = len(t)

for i in range(0,n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if(s[i]+s[j]+s[k] not in l):
                l.append(s[i]+s[j]+s[k])
                res += 1
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  c = [i//100,(i//10)%10,i%10]
  f=0
  for j in range(n):
    if(s[j]==chr(c[f])): f+=1
    if(f==3): break
  if(f==3): cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
cnt=0
for i in range(1000):
  c = [i//100,(i//10)%10,i%10]
  f=0
  for j in range(n):
    if((s[j])==chr(c[f])): f+=1
    if(f==3): break
  if(f==3): cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())

T=[]
c=0
for i in range(10):
  T=S
  i=str(i)
  if i in T[:N-2]:
    indx_i=T.index(i) 
    for j in range(10):
      j=str(j)
      if j in T[indx_i+1:N-1]:
        indx_j=indx_i+T[indx_i+1:].index(j)+1
        for k in range(10):
          k=str(k)
          if k in T[indx_j+1:]:
            c+=1
            print(i,j,k)

print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

ans = 0

for i in range(10):
    a = S.find(str(i))
    if -1 == a:
        continue
    for j in range(10):
        b = S.find(str(j), a + 1)
        if -1 == b:
            continue
        for k in range(10):
            c = S.find(str(k), b + 1)
            if -1 == c:
                continue
            ans += 1
            print(''.join(map(str, [i, j, k])))

print(ans)

Submission status: Wrong Answer

Solution code:
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import sys
# import bisect
# import numpy as np
# from scipy.special import comb


def main():

    N = int(input())
    S = input()

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = False
        d2_flag = False

        for j in S:
            now = int(j)
            if not d1_flag and d1 == now:
                d1_flag = True
            elif not d2_flag and d2 == now:
                d2_flag = True
            elif d3 == now:
                ans += 1
                #print(d1, d2, d3)
                break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
val1=input()
s=input()
n=int(val1)

data=np.zeros(1000,dtype=int)

for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            data[int(s[i]+s[j]+s[k])]+=1
np.count_nonzero(data)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

pins = []
for i in range(1000):
    i = str(i)
    if len(i) == 1:
        pins.append(str('00')+i)
    elif len(i) == 2:
        pins.append(str('0')+i)
    else:
        pins.append(i)

ans = 0
for pin in pins:
    c = 0
    for i in s:
        if pin[c] == i:
            c += 1
        if c == 3:
            ans += 1
            break

print(pins)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

pins = []
for i in range(1,1000):
    i = str(i)
    if len(i) == 1:
        pins.append(str('00')+i)
    elif len(i) == 2:
        pins.append(str('0')+i)
    else:
        pins.append(i)

ans = 0
for pin in pins:
    c = 0
    for i in s:
        if pin[c] == i:
            c += 1
        if c == 3:
            ans += 1
            break

print(ans)

Submission status: Wrong Answer

Solution code:

import sys

n=int(input())
a=list(map(int,input().split()))

if a[0]!=0:
    print(0)
    sys.exit()
 
mod=10**9+7
acnt=dict()
acnt[a[0]]=1
acntkeymax=0
t=3
for i in range(1,n):

    if a[i] in acnt:
        acnt[a[i]]+=1
        if acnt[a[i]]>3:
            print(0)
            sys.exit()
    else:
        if acntkeymax+1==a[i]:
            acntkeymax=a[i]
            acnt[a[i]]=1
        else:
            print(0)
            sys.exit()

    if a[i]!=0:
        if acnt[a[i]-1]==1:
            if acnt[a[i]]!=1:
                print(0)
                sys.exit()
        elif acnt[a[i]-1]==2:
            if acnt[a[i]]==1:
                t=(t*2)%mod
            elif acnt[a[i]]!=2:
                print(0)
                sys.exit()
        elif acnt[a[i]-1]==3:
            if acnt[a[i]]==1:
                t=(t*3)%mod
            elif acnt[a[i]]==2:
                t=(t*2)%mod
            elif acnt[a[i]]!=3:
                print(0)
                sys.exit()
    else:
        if acnt[0]==2:
            t=(t*2)%mod
        elif acnt[0]!=3:
            print(0)
            sys.exit()

#    print("i:",i,"a[i]:",a[i],"acnt[a[i]]:",acnt[a[i]],"t:",t)
                
print(t)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=int(input())

lis=[]
for i in range(1,10):
  for j in range(1,10):
    for k in range(1,10):
      lis.append(str(i)+str(j)+str(k))

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 
lst.reverse()
print(lst)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
ans = 0
 
pin = [str(i).zfill(3) for i in range(1000)]
 
for i in pin:
    idx = -1
    for j in i:
        idx = s.find(j,idx+1)
        if idx < 0:
            break
    else:
        print(j)
        ans += 1
 
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
print(s)
cnt = 0
for s1 in range(10):
    s1_ind = s.find(str(s1))
    if s1_ind == -1 or s1_ind >= len(s)-2 : continue
    for s2 in range(10):
        s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
        if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
        for s3 in range(10):
            s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
            if s3_ind > s2_ind: 
                cnt+=1

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(str(input()))

used = [0]*1000

for i in range(1000):
  stri = str(i)
  if len(stri) == 2:
    stri = "0"+stri
  elif len(stri) == 1:
    stri = "00"+stri
  count = 0
  for j in range(N):
    if S[j] == stri[count]:
      count += 1
    if count == 3:
      print(i)
      used[i] = 1
      break

print(sum(used))