Logo
(追記) (追記ここまで)

31524번 - Magic Cube 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 2048 MB1511975.000%

문제

Imagine you are holding an $n \times n \times n$ cube, which is split up into $n^3$ smaller cubes labeled from 1 to $n^3$. The orientation of the axes is left-to-right for the $x$-axis, back-to-front for the $y$-axis, and bottom-to-top for the $z$-axis. For example, a 2ドル \times 2 \times 2$ cube is labeled as such:

Bottom layer ($z=1$):

1 2 
3 4

Top layer ($z=2$):

5 6 
7 8

In the context of a 2ドル \times 2 \times 2$ cube:

  • Cube 1 is at (1, 1, 1).
  • Cube 2 is at (2, 1, 1).
  • Cube 3 is at (1, 2, 1).
  • Cube 5 is at (1, 1, 2).

Each time you rotate the cube at slice $k$ along one of the $x$-, $y$-, and $z$- axes, you are rotating the $(k+1)$th layer along the corresponding axis, as well as all the layers after $k$ in the increasing direction of that axis.

입력

The first line contains two integers, $n$ (2ドル \leq n \leq 1,000円$) and $m$ (1ドル \leq m \leq 2,000円$), the size of the cube and the number of operations.

Each of the next $m$ lines contains the information regarding an operation, and will be one of the following:

  • x, $\theta,ドル $k$: Rotate slices $k+1$ through slice $n$ by $\theta$ degrees counterclockwise around the $x$-axis.
  • y, $\theta,ドル $k$: Rotate slices $k+1$ through slice $n$ by $\theta$ degrees counterclockwise around the $y$-axis.
  • z, $\theta,ドル $k$: Rotate slices $k+1$ through slice $n$ by $\theta$ degrees counterclockwise around the $z$-axis.
  • q x y z: This is a query operation. Output which cube is at location $(x, y, z)$.

For the first three operations, it is guaranteed that 0ドル \leq k \leq n-1$ and $\theta \in \{90, 180, 270, 360\}$. For queries, $(x, y, z)$ denotes the query location and 1ドル \leq x, y, z \leq n$. It is guaranteed there will be at least one query. The cube does not reset between operations. That is, rotations are cumulative.

출력

For each query operation, output which cube is at the given location.

제한

예제 입력 1

2 8
x 360 1
y 360 1
q 1 1 2
z 90 1
x 360 1
q 1 2 1
q 2 1 1
q 2 2 2

예제 출력 1

5
3
2
7

예제 입력 2

2 7
x 180 1
q 1 1 1
q 1 1 2
y 270 1
q 2 1 1
q 2 1 2
q 2 2 1

예제 출력 2

1
5
8
4
2

예제 입력 3

3 7
y 270 1
q 1 1 1
q 1 2 3
z 360 2
q 3 2 1
q 2 2 2
q 3 3 3

예제 출력 3

1
4
24
14
25

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2023 ICPC Pacific Northwest Region > Division 2 L번

  • 문제를 만든 사람: Yingying Wu
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /