Uva-118-Mutant Flatworld Explorers
来源:互联网 发布:淘宝二手雷蛇耳麦 编辑:程序博客网 时间:2024/05/21 11:19
简单的模拟题,就是给你一系列指令,然后进行模拟操作。
代码:
#include<cstdio>#include<cstring>#include<iostream>#define MAX 10001bool lost[MAX][MAX];int n,m,sx,sy,pos;char s[4];int movey[4]={1,0,-1,0},movex[4]={0,1,0,-1};int GetPos(char op){ switch(op) {case 'N':return 0;case 'E':return 1;case 'S':return 2;case 'W': return 3; }}bool islost(int x,int y){ if(x<0||y<0||x>n||y>m)return true; return false;}char GetS(int pos){ switch(pos) {case 0:return 'N';case 1:return 'E';case 2:return 'S';case 3:return 'W'; }}int main(){ scanf("%d%d",&n,&m); memset(lost,0,sizeof(lost)); while(scanf("%d%d%s",&sx,&sy,&s)!=EOF) {pos=GetPos(s[0]);char str[MAX];scanf("%s",str);int flag=0;for(int i=0;i<strlen(str);i++){ if(str[i]=='F') {if(islost(sx+movex[pos],sy+movey[pos])){ if(lost[sx][sy])continue; else {lost[sx][sy]=1;flag=1;break; }}sx+=movex[pos];sy+=movey[pos]; } else if(str[i]=='R')pos=(pos+4+1)%4; elsepos=(pos+4-1)%4;}printf("%d %d",sx,sy);printf(" %c",GetS(pos));if(flag) printf(" LOST");printf("\n"); } return 0;}
- Uva-118-Mutant Flatworld Explorers
- UVA 118 Mutant Flatworld Explorers
- UVa 118 - Mutant Flatworld Explorers
- UVa 118|Mutant Flatworld Explorers|
- UVa Problem 118 - Mutant Flatworld Explorers
- UVa 118 Mutant Flatworld Explorers (模拟机器人移动)
- Mutant Flatworld Explorers
- Check if a File is in Internet Explorers Cache
- 'Visual Studio Explorers and Designers Package' has failed to load properly
- Web应用漏洞fuzz工具 – teenage mutant ninja turtles V 1.5
- 枚举进程句柄File,Section,Mutant,Timer关闭Mutex句柄实现游戏多开
- 枚举进程句柄File,Section,Mutant,Timer关闭Mutex句柄实现游戏多开
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- 黑马程序员_java入门_IO流_5(文件概述)
- [Python]入门教程(二):Python中的一些基本概念
- win7自带的xps viewer很好用
- MySQL 存储过程 函数 区别
- Android 蓝牙源码结构与协议简介
- Uva-118-Mutant Flatworld Explorers
- 【python】crontab调用python的注意事项
- C#获取指定目录包含的文件和子目录
- Android自带的toolbox分析及扩展
- 当你输入一个网址的时候,实际会发生什么?
- 那些年解决的 Ubuntu 系统故障
- mac使用总结
- Quad-Band含义及国内GSM频谱现状
- 00_wamp开发环境搭建