import java.util.*;
public class U2407p26 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int s = sc.nextInt();
List<String> ss = new ArrayList<>();
String step = "";
int a = 0;
while(s>a){
a++;
String temp = sc.next();
step = step.concat(temp);
ss.add(temp);
}
int f = 50/s;
int y = 50%s;
List<String> ss2 = new ArrayList<>();
while (f > 0){
ss2.add(step);
f--;
}
if (y != 0){
String ll = "";
for (int t = 0; t < y;t++){
ll = ll.concat(ss.get(t));
}
ss2.add(ll);
}
int[][] start = new int[][]{{0,0}};
String direction = "北";
Map<Integer,int[][]> map = new HashMap<>();
char[] chars = step.toCharArray();
int m =0;
for(int j = 0 ; j < ss2.size()*4;j++){
for (int i = 0; i < step.length(); i++){
if(chars[i] == 'S'){
m++;
switch (direction){
case "北":{
int[][] locate = new int[][]{{0,1}};
start = getLocate(start,locate);
map.put(m,locate);
break;
}
case "东":{
int[][] locate = new int[][]{{1,0}};
start = getLocate(start,locate);
map.put(m,locate);
break;
}
case "南":{
int[][] locate = new int[][]{{0,-1}};
start = getLocate(start,locate);
map.put(m,locate);
break;
}
case "西":{
int[][] locate = new int[][]{{-1,0}};
start = getLocate(start,locate);
map.put(m,locate);
break;
}
}
}
if(chars[i] == 'L'){
for (int ii = 0; ii < 4; ii++){
if (direction == "北"){
direction = "西";
break;
}
if (direction == "西"){
direction = "南";
break;
}
if (direction == "南"){
direction = "东";
break;
}
if (direction == "东"){
direction = "北";
break;
}
}
}
if(chars[i] == 'R'){
for (int ii = 0; ii < 4; ii++){
if (direction == "北"){
direction = "东";
break;
}
if (direction == "东"){
direction = "南";
break;
}
if (direction == "南"){
direction = "西";
break;
}
if (direction == "西"){
direction = "北";
break;
}
}
}
}
if (start[0][0] == 0 && start[0][1] == 0 ){
System.out.println("bounded");
return;
}
}
if (start[0][0] != 0 || start[0][1] != 0 ){
System.out.println("unbounded");
}else{
System.out.println("bounded");
}
}
private static int[][] getLocate(int[][] source, int[][] dest){
return new int[][]{{dest[0][0] + source[0][0],dest[0][1] + source[0][1]}};
}
}
解救公主游戏
最新推荐文章于 2021-02-25 17:50:10 发布