A44 - Change and Reverse
https://atcoder.jp/contests/tessoku-book/tasks/tessoku_book_ar
提出
code: python
n, q = map(int, input().split())
query = list(map(int, input().split())) for _ in range(n-1)
a = i for i in range(1, n+1)
for q in query:
if q0 == 1:
a[q1-1] = q2
elif q0 == 2:
# 反転
print()
else:
print(a[q1-1])
解答
code: python
N, Q = map(int, input().split())
State = 1
E = None * (N+2)
for i in range(1, N+1):
Ei = i
for i in range(Q):
Query = input().split()
if int(Query0) == 1:
x = int(Query1)
y = int(Query2)
if State == 1:
Ex = y
if State == 2:
EN+1-x = y
if int(Query0) == 2:
if State == 1:
State = 2
else:
State = 1
if int(Query0) == 3:
x = int(Query1)
if State == 1:
print(Ex)
if State == 2:
print(EN+1-x)