1s = input()
2op = ''
3for i in range(len(s)-1):
4 if s[i]==s[i+1]:
5 op += s[i]
6 op += '*'
7 else:
8 op += s[i]
9op += s[-1]
10print(op)
1val = input().split(' ')
2nums = input().split(' ')
3levels = []
4for _ in range(int(val[1])):
5 levels.append(int(input()))
6nums = [int(x) for x in nums]
7for idx in range(int(val[1])):
8 r = [x for x in nums if x >= levels[int(idx)]]
9 print(min(r))
1s = input()
2op = ''
3for i in range(len(s)-1):
4 if s[i]==s[i+1]:
5 op += s[i]
6 op += '*'
7 else:
8 op += s[i]
9op += s[-1]
10print(op)
1graph = {'S':{'A':1, 'C':2}, 'A':{'B':6}, 'B':{'D':1, 'E':2}, 'C':{'A':4, 'D':3}, 'D':{'E':1}, 'E':{}} #we illustrate the dijkstra graph
2
3def dijkstra(graph,start,target):
4 # we set all the default value first for all variable
5 shortest_distance = {}
6 previous = {}
7 unvisitNodes = graph
8 infinity = 999999999
9 pathway = []
10
11 # for loop to check wether node have visit or not
12 # if the node in unvisit nodes, set the shortest distance for the node to infinity
13 # Set the shortest distance for start node to 0
14 for node in unvisitNodes:
15 shortest_distance[node] = infinity
16 shortest_distance[start] = 0
17
18 # while loop to decide the next node will be visit
19 # for first time around, it start with start node (itself)
20 #
21 while unvisitNodes:
22 minNode = None
23 for node in unvisitNodes:
24 if minNode is None:
25 minNode = node
26 elif shortest_distance[node] < shortest_distance[minNode]:
27 minNode = node
28
29 # for loop to calculate shortest distance target node form start node
30 # update the short distance target node from start node if calculate distance is less than known distance
31 # initialize the previous node for each calculate node
32 # decide the next node will be visit by the smallest known distance from start vertex
33 # add the node into visited node
34 for neighbourNode, weight in graph[minNode].items():
35 if weight + shortest_distance[minNode] < shortest_distance[neighbourNode]:
36 shortest_distance[neighbourNode] = weight + shortest_distance[minNode]
37 previous[neighbourNode] = minNode
38 unvisitNodes.pop(minNode)
39
40 #set currentNode into target
41 currentNode = target
42 #while loop to list all the path way for the calculate nodes
43 while currentNode !=start:
44 try:
45 pathway.insert(0,currentNode)
46 currentNode = previous[currentNode]
47 except KeyError:
48 print('Path not reach')
49 break
50 #add start node into the path way for each calculate nodes
51 pathway.insert(0,start)
52 #display the shortest distance and the path way for each target nodes
53 if shortest_distance[target] != infinity:
54 print('You are required shortest distance and path:- ')
55 print('From: ' + str(start))
56 print('To: ' + str(target))
57 print('Shortest distance for ' + str(target) + ' from ' + str(start) + ' is ' + str(shortest_distance[target]))
58 print('The path is ' + str(pathway))
59
60
61# call the dijkstra function by assign the start and target nodes as the parameter
62dijkstra(graph,'S','S')
63