from itertools import combinations
wyn = 0
wyst = set()
zlicz = set()
n,q = map(int, input().split())
slowo = input()
lslowo = list(slowo)
for i in range(n+1):
for komp in combinations(lslowo, i+1):
if komp in wyst:
if not komp in zlicz:
zlicz.add(komp)
wyn+=1
else:
wyst.add(komp)
print(wyn)
for _ in range(q):
wyst.clear()
zlicz.clear()
wyn = 0;
nr, lit = input().split()
lslowo[int(nr)-1] = lit
for i in range(n+1):
for komp in combinations(lslowo, i+1):
if komp in wyst:
if not komp in zlicz:
zlicz.add(komp)
wyn+=1
else:
wyst.add(komp)
print(wyn)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | from itertools import combinations wyn = 0 wyst = set() zlicz = set() n,q = map(int, input().split()) slowo = input() lslowo = list(slowo) for i in range(n+1): for komp in combinations(lslowo, i+1): if komp in wyst: if not komp in zlicz: zlicz.add(komp) wyn+=1 else: wyst.add(komp) print(wyn) for _ in range(q): wyst.clear() zlicz.clear() wyn = 0; nr, lit = input().split() lslowo[int(nr)-1] = lit for i in range(n+1): for komp in combinations(lslowo, i+1): if komp in wyst: if not komp in zlicz: zlicz.add(komp) wyn+=1 else: wyst.add(komp) print(wyn) |
English