当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2789:Pixel Shuffle

题目描述

Shuffling the pixels in a bitmap image sometimes yields random looking images. However, by repeating the shuffling enough times, one finally recovers the original images. This should be no surprise, since ``shuffling" means applying a one-to-one mapping (or permutation) over the cells of the image, which come in finite number.
Problem
Your program should read a number n , and a series of elementary transformations that define a ``shuffling" φ of n x n images. Then, your program should compute the minimal number m (m > 0) , such that m applications of φ always yield the original n x n image.

For instance if φ is counter-clockwise 90o rotation then m = 4 .
输入解释
Input is made of two lines, the first line is number n ( 2<=n<=210 , n even). The number n is the size of images, one image is represented internally by a n x n pixel matrix (aji) , where i is the row number and j is the column number. The pixel at the upper left corner is at row 0 and column 0.

The second line is a non-empty list of at most 32 words, separated by spaces. Valid words are the keywords id, rot, sym, bhsym, bvsym, div and mix, or a keyword followed by ``-". Each keyword key designates an elementary transform (as defined by Figure 1), and key- designates the inverse of transform key. For instance, rot- is the inverse of counter-clockwise 90o rotation, that is clockwise 90o rotation. Finally, the list k1, k2,..., kp designates the compound transform φ = k1ok2o ... okp . For instance, ``bvsym rot-" is the transform that first performs clockwise 90o rotation and then vertical symmetry on the lower half of the image.

输出解释
Your program should output a single line whose contents is the minimal number m (m > 0) such that φm is the identity. You may assume that, for all test input, you have m < 231 .
输入样例
256
rot- div rot div
输出样例
8
提示
If the input is:
256
bvsym div mix
Then, correct output is:
63457

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2789

最后修改于 2020-10-29T06:44:09+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000 65536