cswork / OA打开练习工作台

SafetyKitOA #1

Image Transformations on Binary Matrix

简单可在线判题

考点(AI 标注)原地数组模拟/实现

Given an n×n binary image matrix, first rotate it clockwise by the specified angle (90, 180, or 270 degrees), then perform a vertical flip if its flag is set, and finally perform a horizontal flip if its flag is set; return the final matrix. A vertical flip swaps the rows top to bottom, and a horizontal flip reverses each row left to right.

The catalog specifies the square matrix, the rotation angles, and the three-step execution order.

输入格式

The first line contains n rotation vertical_flip horizontal_flip. Each of the next n lines contains n integers, each 0/1. Bounds on this site: 1≤n≤500; rotation∈{90,180,270}; both flags are 0 or 1.

输出格式

Output n lines, each with n integers, representing the transformed matrix.

样例 1

输入:

2 90 1 1
1 0
0 0

输出:

0 0
1 0

样例 2

输入:

2 180 0 0
1 0
0 1

输出:

1 0
0 1

样例 3

输入:

2 270 1 0
1 1
0 0

输出:

1 0
1 0