###### UVa 11507 - Bender B. Rodríguez Problem

可以向上下左右四個方向偏轉（可以不偏轉，如果數據為No），問最後射線的方向。

#include <cstring>
#include <cstdio>

int L[100001];

// +x:0, -x:1, +y:2, -y:3, +z:4, -z:5
int maps[6][6] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
2, 3, 1, 0, 4, 5,
3, 2, 0, 1, 4, 5,
4, 5, 2, 3, 1, 0,
5, 4, 2, 3, 0, 1,
};

char output[6][3] = {
"+x", "-x", "+y", "-y", "+z", "-z",
};

int main()
{
int  n;
char buf[3];
while (~scanf("%d",&n) && n) {
for (int i = 1; i < n; ++ i) {
scanf("%s",buf);
if (buf[1] == 'x') {
L[i] = (buf[0]=='+')?0:1;
}else if (buf[1] == 'y') {
L[i] = (buf[0]=='+')?2:3;
}else if (buf[1] == 'z') {
L[i] = (buf[0]=='+')?4:5;
}else {
L[i] = -1;
}
}

int state = 0;
for (int i = 1; i < n; ++ i) {
if (L[i] != -1) {
state = maps[L[i]][state];
}
}

puts(output[state]);
}
return 0;
}

#### UVa 11507 Bender B. Rodríguez Problem (模拟&异或)

2013-10-07 00:31:51

#### UVa11507 - Bender B. Rodríguez Problem

2014-08-16 01:19:42

#### ROSCon会议详细资料

2017-02-09 14:03:06

#### Problem 28

2011-05-31 15:54:00

#### UVA, 105 The Skyline Problem

2017-03-29 23:05:27

#### UVa 750 - 8 Queens Chess Problem

2014-09-30 16:12:59

#### UVa 105 - The Skyline Problem

2012-11-21 10:02:19

#### Bender字体

2014年04月30日 218KB 下载

#### 3n+1_problem_Uva

2016-04-30 22:49:03

#### UVa 524 - Prime Ring Problem（回溯）

2015-03-13 17:59:53

## 不良信息举报

UVa 11507 - Bender B. Rodríguez Problem