-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP2_989B.py
More file actions
50 lines (44 loc) · 954 Bytes
/
P2_989B.py
File metadata and controls
50 lines (44 loc) · 954 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
##########################
## A Tide of Riverscape ##
##########################
def main():
n,p = input().split(" ")
s = input()
n = int(n)
p = int(p)
aux = 0
menor = []
maior = []
for i in range(n-p):
menor.append(i+1)
maior.append(i+1+p)
for i in range(len(menor)):
if(s[menor[i]-1] == '.' and s[maior[i]-1] != '.'):
if(s[maior[i]-1] == '0'):
print(s.replace('.','1'))
else:
print(s.replace('.','0'))
aux = 1
break
elif(s[menor[i]-1] != '.' and s[maior[i]-1] == '.'):
if(s[menor[i]-1] == '0'):
print(s.replace('.','1'))
else:
print(s.replace('.','0'))
aux = 1
break
elif(s[menor[i]-1] == '.' and s[maior[i]-1] == '.'):
novo = list(s)
novo[menor[i]-1] = '0'
s = ''.join(novo)
print(s.replace('.','1'))
aux = 1
break
elif(s[menor[i]-1] != s[maior[i]-1]):
print(s.replace('.','0'))
aux = 1
break
if(aux == 0):
print("No")
if __name__ == "__main__":
main()