编程介的小学生 2018-11-28 15:51 采纳率: 20.5%
浏览 475
已采纳

在这个问题里,如何计算出CA和CB的,比较模糊的问题,谢谢

Problem Description
In the 22nd Century, more than one hundred million people attend the Mahjong Sports all over the world. Professional Mahjong players are getting more and more attentions. In many high schools, there’ll be a large-scale Mahjong match every year to select talented students to attend the National Olympiad in Mahjong. For high scores to prove themselves and eager to be a professional Mahjong player someday, students compete with each other for the honor of the Mahjong.
Saki, a girl whose mother and elder sister are professional Mahjong players, will attend the National Olympiad in Mahjong in province (NOMP) this year. To beat other high school, achieve the first prize and attend the National Olympiad in Mahjong (NOM), she and her friends decide to make a camp to train their Mahjong skill.
A very important skill of Mahjong match is to control power of the game. A good Mahjong player could control the game, even all tiles of the game, just like Amae Koromo, whose favorite skill is "catching the moon from the bottom of the sea". This time, Saki and her friends are training their control skill of the Mahjong tiles via the following way.

Saki got a lot of colored Mahjong tiles, and put them into an n * n matrix. Assume there are no more than two Mahjong tiles with the same color. Saki wants to use the Psychic force to control the tiles to the specified state. She could do two kinds of operation as follows:
A. To choose a row arbitrarily, and then swap two tiles' position in this row. This operation will cost CA magic power.
B. To choose a column arbitrarily, and then swap two tiles' position in this column. This operation will cost CB magic power.
Moreover, if you do the same kind of operation as you just did, the operation will cost no power. For example, Saki could make operation BAAAAA but just cost CB+CA magic power. Saki wants to know how to do the operations to finish the task with the least cost.

Input
There are several cases.
The first line is an integer T (T < = 20), indicating the test cases.
Each case starts with three integers n, CA, CB, (1<=n<=300, 1<=CA, CB<=10^6). then 2*n*n integer follows, indicating the initial state and the target state of the grid. Each integer Aij(1<=Aij<=10^5) represent a Mahjong tile.

Output
For each test case, you should output the minimum cost of the game. If Saki couldn't finish the game, output "Take off the shoes!" instead. The output format is as follows.

Sample Input
3
3 16 9
2 5 6
1 1 3
7 8 3
2 5 1
3 3 6
7 8 1
2 193 43
1 2
2 1
1 2
2 2
3 10 20
1 2 3
4 5 4
3 2 1
2 1 2
1 5 3
4 3 4

Sample Output
Case #1: 34
Case #2: Take off the shoes!
Case #3: 30

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-02-16 23:35
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算