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:
N = int(input())
S = list(str(input()))
used = [0]*1000
for i in range(1,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:
      used[i] = 1
      break

print(sum(used))

Submission status: Wrong Answer

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

for i in range(1,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:
      ans += 1
      break

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    import itertools
    n = int(stdin.readline().rstrip())
    s = str(stdin.readline().rstrip())
    g = set({})

    for key in itertools.combinations(s,3):
        g.add(key)
    
    print(len(g))

Submission status: Wrong Answer

Solution code:
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import sys


def main():
    N = int(input())  # 桁数
    S = str(input())

    ans = set()

    digit1 = set()
    digit2 = set()
    digit3 = set()

    for i in range(0, N - 2):
        if S[i] in digit1:
            continue
        digit1.add(S[i])
        for j in range(i + 1, N - 1):
            if S[j] in digit2:
                continue
            digit2.add(S[j])
            for k in range(j + 1, N):
                if len(digit3) == 10:
                    break
                code = S[i] + S[j] + S[k]
                ans.add(code)

    print(len(ans))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[int(c) for c in input()]
count=0
for p in range(10):
    for q in range(10):
        for r in range(10):
            flag=False
            if p in s[:n-2]:
                inp=s.index(p)
                if q in s[inp+1:n-1]:
                    inq=s[inp+1:n-1].index(q)
                    if r in s[inq+1:]:
                        count+=1
                        flag=True
                        break
        if flag: break
    if flag: break
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
count=0
for p in range(10):
    for q in range(10):
        for r in range(10):
            for i in range(0,n-2):
                if p==int(s[i]):
                    for j in range(i+1,n-1):
                        if q==int(s[j]):
                            for k in range(j+1,n):
                                if r==int(s[k]): 
                                    count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
count=0
for p in range(10):
    for q in range(10):
        for r in range(10):
            flag=False
            for i in range(0,n-2):
                if s.count(str(p))>=3 or p==int(s[i]):
                    for j in range(i+1,n-1):
                        if s.count(str(q))>=3 and q==int(s[j]):
                            for k in range(j+1,n):
                                if s.count(str(r))>=3 and r==int(s[k]): 
                                    count+=1
                                    flag=True
                                    break
                        if flag: break
                if flag: break
print(count)

Submission status: Wrong Answer

Solution code:

n=int(input())
s=list(input())

pin=set()
for i in range(1,1000):
    yn=""
    stri=format(i,"03d")
    for ii in range(n-2):
        if stri[0]!=s[ii]:
            continue
        else:
            yn="yes1"
            break
    if yn!="yes1":
        yn="no"
        continue
    for iii in range(ii+1,n-1):
        if stri[1]!=s[iii]:
            continue
        else:
            yn="yes2"
            break
    if yn!="yes2":
        yn="no"
        continue
    for iiii in range(iii+1,n):
        if stri[2]!=s[iiii]:
            continue
        else:
            yn="yes3"
            break
    if yn=="yes3":
        pin.add(stri)

print(len(pin))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
s = [i for i in input()]
p = set()
for v in itertools.combinations(s, 3):
  if v[0]+v[1]+v[2] in p:
    p.add(v[0]+v[1]+v[2])
print(len(p))

Submission status: Wrong Answer

Solution code:
import re
N = int(input())
S = input()
ans = 0
tmp = [[m.start() for m in re.finditer(str(i), S)] for i in range(10)]
print(tmp)
for i in range(10):
  if len(tmp[i]) == 0:
    continue
  for j in range(10):
    if len(tmp[j]) == 0:
      continue
    for k in range(10):
      if len(tmp[k]) == 0:
        continue
      l = tmp[i][0]
      r = tmp[k][-1]
      for m in range(l+1, r):
        if m in tmp[j]:
          ans += 1
          break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
lst = [0] * 1000
for i in range(1000):
    if len(str(i)) == 1:
        tmp = '00' + str(i)
        lst[i] = tmp
    elif len(str(i)) == 2:
        tmp = '0' + str(i)
        lst[i] = tmp
    else:
        lst[i] = str(i)

cnt = 0
for v in lst:
    id_1 = s.find(v[0])
    if id_1 == -1:
        continue
    id_2 = s.find(v[1], id_1 + 1)
    if id_2 == -1:
        continue
    id_3 = s.find(v[2], id_2 + 1)
    if id_3 == -1:
        continue
    cnt += 1

Submission status: Wrong Answer

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

results = set()

for i in range(1000):
    # 対象となる3桁の数字を用意
    filled_num = str(i).zfill(3)
    target = list(filled_num)
    count = 0
    index = 0
    for j in range(3):
        for k in range(index, len(S), 1):
            if S[k] == target[j]:
                count += 1
                index = k + 1
                break
    if count == 3:
        print(filled_num)
        results.add(filled_num)

print(len(results))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
s = input()
counter = 0
for i in range(1, 10 ** 3):
  phrase = ('00' + str(i))[-3:]
  if phrase[0] in s:
    s2 = s[s.index(phrase[0]) + 1:]
    if phrase[1] in s2:
      s3 = s2[s2.index(phrase[1]) + 1:]
      if phrase[2] in s3:
        counter += 1
print(counter)

Submission status: Wrong Answer

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

ans_str = [elem for i, elem in enumerate(s) if s[i] != s[i-1]]

ans = []
for i, i_elem in enumerate(ans_str):
    for j, j_elem in enumerate(ans_str):
        for k, k_elem in enumerate(ans_str):
            if i<j<k and '{}{}{}'.format(i_elem, j_elem, k_elem) not in ans:
                ans.append('{}{}{}'.format(i_elem, j_elem, k_elem))

print(len(ans))

Submission status: Wrong Answer

Solution code:
import itertools 
N=int(input())
S=list(input())
int_list=[x for x in range(N)]
ans_cand=[]
del_list=itertools.combinations(int_list,3)

for lists in del_list:
    tmp=""
    for i in range(N):
        if i not in lists:
            tmp+=S[i]
    ans_cand.append(tmp)
print(len(set(ans_cand)))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
L = list(S)
first = [L.index(str(i)) if str(i) in S else None for i in range(10)]
con = 0

for i in range(10):
  if str(i) in first:
    p = first[i]
    for j in range(10):
      if str(j) in S[p + 1]:
        q = S[p + 1].index(j)
        for k in range(10):
          if str(k) in S[q + 1]:
            con += 1

print(con)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = list(map(int,input()))
keys = [i for i in range(10)]
values = [0 for _ in range(10)]
e = dict(zip(keys, values))
for i in range(n):
    c = s[i]
    e[c] += 1

ans = 0
l = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            b = str(i) + str(j) + str(k)
            l.append(b)
for i in l:
    done = True
    d = e.copy()
    for j in range(3):
        a = i[j]
        d[int(a)] -= 1
    for k in d.values():
        if k < 0: 
            done = False
            break
        else: 
            pass
    if done: ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
sum = input()

if len(sum) < 3:
    print('0')
else:
    last_2_digit = sum[-2:]
    upper_digit = sum[:-2]

    if last_2_digit == '00':
        print('1')
    else:
        required_num = int(last_2_digit - 1) // 5 + 1
        print(upper_digit, last_2_digit, required_num)
        if int(upper_digit) >= required_num:
            print('1')
        else:
            print('0')

Submission status: Wrong Answer

Solution code:
import math
import itertools
import numpy as np
        
def solve():
    n = int(input())
    s = input()
    pat = []
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(i+2, n):
                pat.append(s[i]+s[j]+s[k])
    print(len(set(pat)))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import math
import itertools
import numpy as np

def solve():
    n = int(input())
    s = input()
    pat = []
    for i in range(n):
        pat.append(s[0:i]+s[i+1:n])
    print(len(list(set(pat))))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()
S = input()

s = set([0])
for n in S:
	n = int(n)
	s |= set(10*x+n for x in s if len(str(x)) != 3)
print(len([x for x in s if len(str(x)) == 3]))

Submission status: Wrong Answer

Solution code:
import collections
import copy

N = int(input().split()[0])
S = input()

counter = collections.Counter(S)
total = 0
done_list = []
for i, ch in enumerate(S[::-1]):  # 3 * 10 ** 4
    if ch in done_list:
        continue
    sub_done_list = []
    counter[ch] = counter[ch] - 1
    if counter[ch] < 1:
        del counter[ch]
    sub_counter = copy.copy(counter)
    for ch_2 in S[:i:-1]:  # 3 * 10 ** 4
        if ch_2 in sub_done_list:
            continue
        sub_done_list.append(ch_2)
        sub_counter[ch_2] = sub_counter[ch_2] - 1
        if sub_counter[ch_2] < 1:
            del sub_counter[ch_2]
        total += len(sub_counter.keys())

    done_list.append(ch)

ans = total

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter as cnt
from collections import defaultdict as dd
import copy
n = int(input())
s = list(input())

count = cnt(s)
num_rest = []
for i in range(n):
  if count[s[i]] == 1:
    del count[s[i]]
  else:
    count[s[i]] -= 1
  num_rest.append(copy.copy(count))
#print(num_rest)


checked = dd(set)
total = 0
for i in range(n-2):
  if len(checked) >= 10:
    break
  for j in range(i+1, n-1):
    #print(s[i], s[j], checked[s[i]])
    if len(checked[s[j]]) >= 10:
      break
    if s[j] not in checked[s[i]]:
      #print(s[i], s[j], num_rest[j])
      checked[s[i]].add(s[j])
      total += len(num_rest[j])
print(total)

Submission status: Wrong Answer

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

ans=0

for i in range(10):
  if str(i) in S:
    a = S.find(str(i))
    for j in range(10):
      if str(j) in S[a+1:]:
      	b = S[a+1:].find(str(j))
      	for k in range(10):
          if str(k) in S[a+b+2:]:
            ans+=1
            print(i,j,k)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

def check(num:int):
    snum = str(num).zfill(3)
    j = 0
    for s in S:
        if s==snum[j]:
            j += 1
        if j==3:
            return True
    else:
        return False

cnt = 0
for i in range(1001):
    if check(i):
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [int(x) for x in list(input())]
total = 0
flag = True
for a in range(100,1000):
  flag = True
  for x in range(N-2):
    if S[x] == a//100:
      for y in range(x+1,N-1):
        if S[y] == a//10%10:
          for z in range(y+1,N):
            if a == S[x]*100+S[y]*10+S[z]:
              flag = False
              total += 1
              break
        if not flag:
          break
    if not flag:
      break
print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = int(input())
print(int(N * (N-1) * (N-2) / 6))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = int(input())
print(N * (N-1) * (N-2) / 6)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
l=set()
for i in range(0,n-2):
    if i>=1 and s[i]==s[0]  :
        break
    for j in range(i+1,n-1):
        # if i>=1 and s[i]==s[0]  :
        #     break
        for k in range(j+1,n):
            # if j>=2 and s[j]==s[1] and i!=1:
            #     break
            m=s[i]+s[j]+s[k]
            l.add(m)



print(len(l))

Submission status: Wrong Answer

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


l={s[1:]}
l.add(s[:-1])

for i in range(1,n-1):
    k=s[:i]+s[i+1:]
    l.add(k)
print(len(l))

Submission status: Wrong Answer

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

ans = 0
for i in range(1, 1000):
    num = str(i).zfill(3)
    flag2 = True
    start = 0
    for j in range(3):
        flag = False
        for k in range(start, N):
            if(num[j] == S[k]):
                flag = True
                start = k+1
                break
        if flag == False:
            flag2 = False
            break
    if flag2:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, 1000):
    num = (3-len(str(i)))*"0"+str(i)
    cnt = 0
    for j in range(len(S)):
        if(S[j] == num[cnt]):
            cnt += 1
            if(cnt == 3):
                ans += 1
                break
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [s for s in input()]
#lis = [str(i)+str(j)+str(k) for i in range(10) for j in range(i,10) for k in range(j,10)]
past = set()
ans = 0
for i in range(N-2):
    for j in range(i,N-1):
        for k in range(j,N):
            if S[i]+S[j]+S[k] not in past:
                past.add(S[i]+S[j]+S[k])
                ans += 1
            else:continue
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
arr = []
cnt = 0
for i in range(1,1000):
    arr = []
    if i <10:
      arr.append("0")
      arr.append("0")
      arr.append(str(i))
    elif i <100:
      arr.append("0")
      arr.append(list(str(i))[0])
      arr.append(list(str(i))[1])
    else:
      arr.append(list(str(i))[0])
      arr.append(list(str(i))[1])
      arr.append(list(str(i))[2])
    for j in S:
      if j == arr[0]:
        arr.pop(0)
      if arr == []:
        cnt += 1
        break

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
arr = []
cnt = 0
for i in range(1,1000):
    if i <10:
      arr.append("0")
      arr.append("0")
      arr.append(str(i))
    elif i <100:
      arr.append("0")
      arr.append(list(str(i))[0])
      arr.append(list(str(i))[1])
    else:
      arr.append(list(str(i))[0])
      arr.append(list(str(i))[1])
      arr.append(list(str(i))[2])
    for j in S:
      if arr == []:
        cnt += 1
        break
      if j == arr[0]:
        arr.pop(0)
    
    
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 13:15:15 2020

@author: liang
"""

"""
1.全探索 i,j,kを固定してそれぞれの番号を調べる => O(N^3)
2.全探索3桁の暗証番号000~999が文字列Sにあるか調べる =>O(N)
"""
"""
解1.コード　=> TLE
#使用済みリストを用意することで枝刈り
N = int(input())
S = list(map(int,input().split()))
num_used = [list() for i in range(10)]
numbers = list()
for i in range(N):
    for j in range(i+1, N):
        if S[j] in num_used[S[i]]:
            continue
        else:
            num_used[S[i]].append(S[j])
            for k in range(j+1,N):
                number = str(S[i]) + str(S[j]) + str(S[k])
                if number not in numbers:
                    numbers.append(number)
print(len(numbers))
"""
#解2コード
N = int(input())
S = input()
ans = 0
for i in range(1000):
    a = i//100
    b = i%100//10 ###400//10 = 40
    c = i%10
    num = str(a) + str(b) + str(c) 
    print(num)
    flag = 0
    for j in range(N) :
        if S[j] == num[flag]:
            flag += 1
        if flag == 3:
            ans += 1
            break
        
            
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 13:15:15 2020

@author: liang
"""

N = int(input())
S = input()
numbers = list()
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1,N):
            number = str(S[i]) + str(S[j]) + str(S[k])
            if number not in numbers:
                numbers.append(number)
print(numbers)
print(len(numbers))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, list(input())))
ans = 0

for i in range(10):
    first = False
    second = False
    for j in range(N):
        if not first:
            if S[j] == 0:
                first = True
                continue
        elif not second:
            if S[j] == 0:
                second = True
                continue
        else:
            if S[j] == i:
                ans += 1
                break

for i in range(11, 100):
    first = False
    second = False
    second_v = i // 10
    third_v = i % 10
    for j in range(N):
        if not first:
            if S[j] == 0:
                first = True
                continue
        elif not second:
            if S[j] == second_v:
                second = True
                continue
        else:
            if S[j] == third_v:
                ans += 1
                break


for i in range(101, 1000):
    first = False
    second = False
    first_v = i // 100
    second_v = i // 10 % 10
    third_v = i % 10
    for j in range(N):
        if not first:
            if S[j] == first_v:
                first = True
                continue
        elif not second:
            if S[j] == second_v:
                second = True
                continue
        else:
            if S[j] == third_v:
                ans += 1
                break

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():

    N=int(input())
    s = str(input())


    l=['%03d'%(p) for p in range(0,10**N)]
    cnt=0
    for i in l:
        for j in range(N):
            if s[j]==i[0]:
                for k in range(j+1,N):
                    if s[k]==i[1]:
                        for m in range(k+1,N):
                            if s[m]==i[2]:
                                cnt+=1

    print(cnt)


resolve()

Submission status: Wrong Answer

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

d = [[] for _ in range(10)]
for i, s in enumerate(S):
    d[int(s)].append(i)
for i in range(10):
    d[i] = sorted(d[i])
ans = 0

for i in range(10):
    if d[i] == []:
        continue
    v = bisect.bisect_left(d[i], 0)
    if v == len(d[i]):
        continue
    l1 = d[i][v]
    for j in range(10):
        if d[j] == []:
            continue
        v = bisect.bisect_left(d[j], l1)
        if v == len(d[j]):
            continue
        l2 = d[j][v]
        for k in range(10):
            if d[k] == []:
                continue
            v = bisect.bisect_left(d[k], l2)
            if v == len(d[k]):
                continue
            l3 = d[k][v]
            if l3 < N:
                if l1 < l2 < l3:
                    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:

def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1001):
        pw = str(i).zfill(3)
        pw_ind = 0
        for s in S:
            if s == pw[pw_ind]:
                pw_ind += 1
                if pw_ind == 3:
                    break
        if pw_ind == 3:
            ans += 1

    return print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
U = set(S)
cnt = [4]*10
for u in U:
  cnt[int(u)] = 0
T = ''
for s in S:
  cnt[int(s)]+=1
  if min(cnt)<=3:
    T += s
#print(T)
ans = 0
P = []
for a in range(10):
  A = str(a)
  k = 0
  ind1 = -1
  while k < len(T)-2:
    t = T[k]
    if A == t:
      ind1 = k
      break
    k += 1
  if ind1 == -1:
    continue
  for b in range(10):
    B = str(b)
    l = ind1+1
    ind2 = -1
    while l < len(T)-1:
      t = T[l]
      if B == t:
        ind2 = l
        break
      l += 1
    #print(a,b,ind1,ind2)
    if ind2 == -1:
      continue
    for c in range(10):
      C = str(c)
      m = ind2+1
      while m < len(T):
        t = T[m]
        if C == t:
          ans += 1
          break
        m += 1
print(ans)

#print(*ans, sep='/n')

Submission status: Wrong Answer

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

cnt = [0]*11
i = 0
T = ''
for s in S:
  cnt[int(s)]+=1
  if min(cnt)<=3:
    T += s
print(T)
ans = 0
P = []
for a in range(10):
  A = str(a)
  k = 0
  ind1 = -1
  while k < len(T)-2:
    t = T[k]
    if A == t:
      ind1 = k
      break
    k += 1
  if ind1 == -1:
    continue
  for b in range(10):
    B = str(b)
    l = ind1+1
    ind2 = -1
    while l < len(T)-1:
      t = T[l]
      if B == t:
        ind2 = l
        break
      l += 1
    #print(a,b,ind1,ind2)
    if ind2 == -1:
      continue
    for c in range(10):
      C = str(c)
      m = ind2+1
      while m < len(T):
        t = T[m]
        if C == t:
          ans += 1
          break
        m += 1
print(ans)

#print(*ans, sep='/n')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from itertools import combinations
def main():
    N = int(input())
    S = input()
    ans = set()
    if N == 4:
        combo = combinations(list(range(4)), 3)
        for c in combo:
            pwd = ""
            for idx in c:
                pwd += S[idx]
            ans.add(pwd)

    elif N == 5:
        combo = combinations(list(range(5)), 3)
        for c in combo:
            pwd = ""
            for idx in c:
                pwd += S[idx]
            ans.add(pwd)
    
    else:
        for i in range(N - 5):
            subS = S[i:i+6]
            combo = combinations(list(range(6)), 3)
            for c in combo:
                pwd = ""
                for idx in c:
                    pwd += subS[idx]
                ans.add(pwd)


    print(len(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
# st = set()
# for i in range(n-2):
#     for j in range(i+1, n-1):
#         for k in range(j+1, n):
#             pin = s[i] + s[j] + s[k]
#             st.add(pin)
# print(st)
count = 0
for i in range(1000+1):
    if len(str(i)) == 1:
        v = "00" + str(i)
    elif len(str(i)) == 2:
        v = "0" + str(i)
    else:
        v = str(i)
    k = 0
    for j in range(len(v)):
        while k < len(s):
            if s[k] == v[j]:
                k += 1
                break
            k += 1
        else:
            break
    else:
        count += 1
print(count)

Submission status: Wrong Answer

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

for i in range(1000):
    i = str(i).zfill(3)

    first = s.find(i[0])
    second = s.find(i[1])
    third = s.find(i[2])

    if first != -1 and second != -1 and third != -1:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

for i in range(1,1000):
    tmp=[]
    if i<10:
        tmp.append(0)
        tmp.append(0)
        tmp.append(i)
    elif 10<=i<100:
        tmp.append(0)
        tmp.append(i//10)
        tmp.append(i%10)
    else:
        tmp.append(i//100)
        tmp.append((i-(i//100)*100)//10)
        tmp.append(i%10)

    for j in range(len(s)-2):
        if int(s[j])==tmp[0]:
            for k in range(j+1,len(s)-1):
                if int(s[k])==tmp[1]:
                    for l in range(k+1,len(s)):
                        if int(s[l])==tmp[2]:
                            ans.add(str(tmp))

f=list(ans)
print(len(f))

Submission status: Wrong Answer

Solution code:
def str_find(S, target, start):
    for i in range(start, len(S)):
        if S[i] == target:
            return i

    return 10**9+7

N = int(raw_input())
S = str(raw_input())

candidates = []

for i in range(9):
    for j in range(9):
        for k in range(9):
            candi = str(i)+str(j)+str(k)
            candidates.append(candi)

ans = 0
for candi in candidates:
    x = candi[0]
    i = str_find(S, x, 0)

    y = candi[1]
    j = str_find(S, y, i+1)

    z = candi[2]
    k = str_find(S, z, j+1)

    if i+j+k< 10**8:
        ans = ans + 1

print ans

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
s = len(S)
total = 0
for i in range(1,1000):
  pin = 0
  h = i // 100
  m = i // 10
  mm = m - h * 10
  l = i % 10
  for j in range(s):
    if str(h) == S[j]:
      pin = 1
      J = j
      break
  if pin == 1:
    for k in range(J+1, s):
      if str(mm) == S[k]:
        pin = 2
        K = k
        break
  if pin == 2:
    for x in range(K+1, s):
      if str(l) == S[x]:
        total += 1
        break
print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
s = len(S)
total = 0
for i in range(1,1000):
  pin = 0
  h = i // 100
  m = i // 10
  mm = m - h * 10
  l = i % 10
  for j in range(s):
    if str(h) == S[j]:
      pin = 1
      J = j
      break
  if pin == 1:
    for k in range(J+1, s):
      if str(mm) == S[k]:
        pin = 2
        K = k
        break
  if pin == 2:
    for x in range(K+1, s):
      if str(l) == S[x]:
        total += 1
        break

Submission status: Wrong Answer

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

delKeta=N-3
ans=[]
n=len(set(S))
if(n<delKeta):
    n=delKeta+1


for i in range(n):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            ans.append(int(S[i]+S[j]+S[k]))
    print(i+1,len(set(ans)))


s=set(ans)
print(len(s))

Submission status: Wrong Answer

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

delKeta=N-3
ans=[]


for i in range(len(set(S))+1):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            ans.append(int(S[i]+S[j]+S[k]))
    #print(i+1,len(set(ans)))


s=set(ans)
print(len(s))

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
s = input()

ans = set()
a_alr = []
b_alr = {}

for i in range(10):
    b_alr[str(i)] = []

for i in range(n-2):
    if(s[i] in a_alr):
        continue
    for j in range(i+1,n-1):
        if(s[j] in b_alr[s[i]]):
            continue
        c_alr = set()
        for k in range(j+1,n):
            c_alr = c_alr | set(s[k])    
            tmp = s[i]+s[j]+s[k]
            ans = ans | set(tmp)
            if(len(c_alr) == 10):
                break

        b_alr[s[i]].append(s[j])
    a_alr.append(s[i])

print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
V = [str(i).zfill(3) for i in range(1000)]
cnt = 0
for v in V:
    tmp = 0
    i = 0
    j = 0
    while i < len(S) and j < len(v):
        if S[i] == v[j]:
            tmp += 1
            j += 1
            i += 1
        else:
            i += 1
    if tmp == 3:
        cnt += 1
        print(v)

print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
  f1=fi(s,i)
  if f1==-1:
    continue
  s1=s[f1+1:]
  for j in range(10):
    f2=fi(s1,j)
    if f2==-1:
      continue
    s2=s1[f2+1:]
    for k in range(10):
      f3=fi(s2,k)
      if f3>0:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
  f1=fi(s,i)
  if f1==-1:
    continue
  s1=s[f1+1:]
  for j in range(10):
    f2=fi(s1,j)
    if f2==-1:
      continue
    s2=s1[f2+1:]
    for k in range(10):
      f3=fi(s1,k)
      if f3>0:
        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
sys.setrecursionlimit(500000)

N = int(readline())
S = readline().decode().rstrip()

ans = 0
for i in range(1000):
    i_ = str(i).zfill(3)
    idx = 0

    for s in i_:
        acc = S[idx:].find(s)
        if idx == -1:
            break
        else:
            idx = acc
    if idx == 3:
        ans += 1

print(ans)

Submission status: Wrong Answer

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


sum = 0
box = []
for i in range(n-2):
    if s[i] not in box:
        box.append(s[i])
    elif len(box) == 10:
        break
    else:
        continue
    box_1 = []
    for j in range(i+1, n-1):
        if s[j] not in box_1:
            box_1.append(s[j])
        elif len(box_1) == 10:
            break
        else:
            continue
        box_2 = []
        for k in range(j+1, n):
            if s[k] not in box_2:
                box_2.append(s[k])
            elif len(box_2) == 10:
                sum += 10
                break
            else:
                continue
        sum += len(box_2)

print(sum)