-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_1244.py
More file actions
50 lines (44 loc) · 1.44 KB
/
Copy pathbj_1244.py
File metadata and controls
50 lines (44 loc) · 1.44 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
49
50
import sys
sys.stdin = open('bj_1244_in.txt', 'r')
input = sys.stdin.readline
s_cnt = int(input().strip())
switches = [999] + list(map(int, input().strip().split()))
# print(switches)
p_cnt = int(input().strip())
people = []
for _ in range(p_cnt):
sex, number = map(int, input().strip().split())
people.append((sex, number))
'''
1: 남자 => 받은 번호의 배수 스위치 변경
2: 여자 => 받은 스위치를 중심으로 양쪽 대칭인 구간 스위치 변경
'''
# print(people)
for person in people:
sex, number = person
s = number # 구간 시작점
e = number # 구간 종료점
if sex == 1: #남자
for i in range(1, s_cnt+1):
if i % number == 0: # 배수면
switches[i] = (1+switches[i]) % 2
else: #여자
#구간 탐색 시작
while s >= 1 and e <= s_cnt: #정상 범위인 구간이면
#다음 구간 탐색
if s-1 >= 1 and e+1 <= s_cnt: #구간 유효성 통과
if switches[s-1] == switches[e+1]: #대칭이면
s -= 1
e += 1
else: #대칭이 아니면
break
else: #유효성 통과 실패
break
for j in range(s, e+1):
switches[j] = (1 + switches[j]) % 2
# switches = switches[1:]
for k in range(1, s_cnt+1):
if k % 20 == 0:
print(switches[k])
else:
print(switches[k], end=' ')