-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem17.py
More file actions
executable file
·48 lines (39 loc) · 1.35 KB
/
Copy pathproblem17.py
File metadata and controls
executable file
·48 lines (39 loc) · 1.35 KB
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
""" Problem:
1 차원 라이프(Life) 게임
국민대학교 소프트웨어융합대학 소프트웨어학부 2학년 20192282 이동국 """
import sys
def solution():
numTestCases = int(input())
for v in range(numTestCases):
[table_len, time] = list(map(int, sys.stdin.readline().split()))
Bac_list = list(map(int,sys.stdin.readline().split()))
while(time):
time -= 1
new_Bac_list = []
for i in range(table_len):
chg = 0
if i == 0:
neighbor = [Bac_list[1]]
elif i == (table_len-1):
neighbor = [Bac_list[i-1]]
else:
neighbor = [Bac_list[i-1], Bac_list[i+1]]
case = sum(neighbor)
if case < 3:
correct_val = Bac_list[i]-1
elif case > 7:
correct_val = Bac_list[i]-1
elif case >= 4 and case <= 7:
correct_val = Bac_list[i]+1
elif case == 3:
correct_val = Bac_list[i]
if correct_val < 0:
correct_val = 0
elif correct_val > 9:
correct_val = 9
new_Bac_list.append(correct_val)
Bac_list = new_Bac_list
Bac_list = list(map(str, Bac_list))
print(" ".join(Bac_list))
if __name__ == "__main__":
solution()