2 shunfurh shunfurh 于 2017.08.29 17:12 提问

Cube Simulation

Here's a cube whose size of its 3 dimensions are all infinite. Meanwhile, there're 6 programs operating this cube:

FILL(X,Y,Z): Fill some part of the cube with different values.

memset(cube, 0, sizeof(cube));
puts("START");
cnt = 0;
for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
        for (int k = 0; k < Z; k++) {
            cube[i][j][k] = ++cnt;
        }
    }
}

SWAP1(x1,x2): Swap two sub-cube along the first dimensions.

for (int j = 0; j < Y; j++) {
    for (int k = 0; k < Z; k++) {
        exchange(cube[x1][j][k], cube[x2][j][k]);
    }
}

SWAP2(y1,y2): Swap two sub-cube along the second dimensions.

for (int i = 0; i < X; i++) {
    for (int k = 0; k < Z; k++) {
        exchange(cube[i][y1][k], cube[i][y2][k]);
    }
}

SWAP3(z1,z2): Swap two sub-cube along the third dimensions.

for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
        exchange(cube[i][j][z1], cube[i][j][z2]);
    }
}

FIND(value): Output the value's location, if it exist.

for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
        for (int k = 0; k < Z; k++) {
            if (cube[i][j][k] == value) {
                printf("%d %d %d\n", i, j, k);
            }
        }
    }
}

QUERY(x,y,z): Output the value at (x,y,z).

printf("%d\n", cube[x][y][z]);

We'll give a list of operations mentioned above. Your job is to simulate the program and tell us what does the machine output in progress.

Input

There'll be 6 kind of operations in the input.

FILL X Y Z (1 <= X, Y, Z <= 1000) for FILL(X,Y,Z)
SWAP1 X1 X2 (0 <= X1, X2 < X) for SWAP1(X1,X2)
SWAP2 Y1 Y2 (0 <= Y1, Y2 < Y) for SWAP2(Y1,Y2)
SWAP3 Z1 Z2 (0 <= Z1, Z2 < Z) for SWAP3(Z1,Z2)
FIND value (value > 0) for FIND(value)
QUERY x y z (0 <= x < X, 0 <= y < Y, 0 <= z < Z) for QUERY(x,y,z)
The input will always start with FILL operation and terminate by EOF.

The number of the operations will less than 200,000, while the FILL operation will less than 100.

Output

Simulate all of the operations in order, and print the output of the programs.

Sample Input

FILL 2 3 1
SWAP1 0 1
SWAP2 0 2
SWAP3 0 0
FIND 1
FIND 2
FIND 3
FIND 4
FIND 5
FIND 6
FIND 7
QUERY 0 0 0
QUERY 0 1 0
QUERY 0 2 0
QUERY 1 0 0
QUERY 1 1 0
QUERY 1 2 0
Sample Output

START
1 2 0
1 1 0
1 0 0
0 2 0
0 1 0
0 0 0
6
5
4
3
2
1

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.13 08:29
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
ZOJ 3429 Cube Simulation
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3429 Cube Simulation Time Limit: 2 Seconds      Memory Limit: 65536 KB Here's a cube whose size of its 3 dimensions ar
Cube Simulation zoj3429 模拟
Description Here’s a cube whose size of its 3 dimensions are all infinite. Meanwhile, there’re 6 programs operating this cube:FILL(X,Y,Z): Fill some part of the cube with different values.memset(cube,
ZOJ 3429 Cube Simulation 解题报告
题目 题意: 三维空间上定义了一些操作,就不翻译了……求每个询问操作的结果 题解: 本来以为很难,后来发现三个坐标是独立的,所以做到当前操作时,可以维护一个映射关系,原本的xi现在应该在xj,就可以直接求了。 难怪过的人最多 //Time:110ms //Memory:204KB //Length:1354B #include #include #include #i
Computer Simulation of Liquids 免费下载
A first in its field, this book is both an introduction to computer simulation of liquids for upper level undergraduates and a how-to guide for specialists. The authors discuss the latest simulation techniques of molecular dynamics and the Monte Carlo methods as well as how to avoid common programming pitfalls. Theoretical concepts and practical programming advice are amply reinforced with examples of computer simulation in action and samples of Fortran code. The authors have also included a wide selection of programs and routines on microfiche to aid chemists, physicists, chemical engineers, and computer scientists, as well as graduate and advanced students in chemistry
ElevatorSimulation
这两天在做一个模拟电梯的程序 通常的办法在Elevator class上直接Paint出电梯来,通过设定Upper left corner 的位置来实现电梯的移动. 但是因为想到如果要给电梯加两个门~~也就是电梯上下人的时候,门开启后关闭。 设想1:改写结构,分离出一个ElevatorRec class,将这个JPanel add在Elevator上,然后再add两个JPanel
solidworks simulation安装方法
指导安装solidworks simulation
SolidWorks Simulation基础教程 2014版.pdf
SolidWorks Simulation基础教程 2014版.pdf
PlantSimulation:Material Flow介绍
PlantSimulation中物料流的相关介绍
SOLIDWORKS Simulation Premium教程 2015版 PDF
SOLIDWORKS Simulation Premium教程 2015版978-7-111-50702-4 _13878633
Simulation With Arena-Kelton
书名:Simulation With Arena 作者:Kelton、 语言:英文 学习ARENA 这个仿真软件,很好的参考书。