POJ2632Crashing Robots
做模拟题做的我直接睡着了,题并不难,就是一个细心的问题,有一些细节问题注意了就差不多了,代码写的精美的一般找错误也好找一些,应该学着些好看的代码
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std ;
int len,high;
int a,b,j ;
struct node
{
int x;
int y ;
int dire;
} s[];
int judge(int k)
{
int i;
if(s[k].x > len||s[k].x< ||s[k].y>high||s[k].y<)
{
printf("Robot %d crashes into the wall\n",k);
return ;
}
for(i = ; i <= a ; i++)
{
if(i == k)
continue;
if(s[i].x == s[k].x&&s[i].y == s[k].y)
{
printf("Robot %d crashes into robot %d\n",k,i);
return ;
}
}
return ;
}
int main()
{
int n ;
cin>>n;
for(int i = ; i <= n ; i++)
{
cin>>len>>high;
cin>>a>>b ;
char dire ;
for(j = ; j <= a ; j++)
{
cin>>s[j].x>>s[j].y>>dire;
if(dire == 'N')
s[j].dire = ;
if(dire == 'W')
s[j].dire = ;
if(dire == 'S')
s[j].dire = ;
if(dire == 'E')
s[j].dire = ;
}
int num,repeat,flag = ;
char order ;
for(j = ; j <= b ; j++)
{
cin>>num>>order>>repeat ;
for(int h = ; h <= repeat ; h++ )//把这个放在外边是为了底下的左右指令时比较好处理
{
if(order == 'F')
{
if(s[num].dire == )
{
s[num].x++ ;
if(!judge(num))
{
flag = ;
break ;
}
}
if(s[num].dire == )
{
s[num].x--;
if(!judge(num))
{
flag = ;
break ;
}
}
if(s[num].dire == )
{
s[num].y++ ;
if(!judge(num))
{
flag = ;
break ;
}
}
if(s[num].dire == )
{
s[num].y--;
if(!judge(num))
{
flag = ;
break ;
}
}
} if(order == 'L')
s[num].dire = (+s[num].dire)% ;
if(order == 'R')
s[num].dire = (s[num].dire-+)%;
}
if(flag == )
break ;
}
if(j < b)
for(++j ; j <= b ; j++)
{
cin>>num>>order>>repeat ;
}
if(flag == )
printf("OK\n");
}
return ;
}
POJ2632Crashing Robots的更多相关文章
- 网站 robots.txt 文件编写
网站 robots.txt 文件编写 Intro robots.txt 是网站根目录下的一个纯文本文件,在这个文件中网站管理者可以声明该网站中不想被robots访问的部分,或者指定搜索引擎只收录指定的 ...
- Robots.txt - 禁止爬虫(转)
Robots.txt - 禁止爬虫 robots.txt用于禁止网络爬虫访问网站指定目录.robots.txt的格式采用面向行的语法:空行.注释行(以#打头).规则行.规则行的格式为:Field: v ...
- (转载)robots.txt写法大全和robots.txt语法的作用
1如果允许所有搜索引擎访问网站的所有部分的话 我们可以建立一个空白的文本文档,命名为robots.txt放在网站的根目录下即可.robots.txt写法如下:User-agent: *Disallow ...
- 2016 ccpc 网络选拔赛 F. Robots
Robots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- robots.txt文件没错,为何总提示封禁
大家好,我的robots.txt文件没错,为何百度总提示封禁,哪位高人帮我看看原因,在此谢过. 我的站点www.haokda.com,robots.txt如下: ## robots.txt for P ...
- robots笔记以免忘记
html头部标签写法: <meta name="robots" content="index,follow" /> content中的值决定允许抓取 ...
- springMVC robots.txt 处理
正常情况这样就好使 <mvc:resources mapping="/robots.txt" location="/lib/robots.txt"/> ...
- poj2632 Crashing Robots
Crashing Robots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9859 Accepted: 4209 D ...
- robots.txt的介绍和写作
目前很多网站管理者似乎对robots.txt并没有引起多大重视,甚至不知道这么一个文件的作用.本来应该保密的信息被爬虫抓取了,公布在公网上,本应该发布到公网的信息却迟迟不被搜索引擎收录.所以下面这篇文 ...
随机推荐
- 记录一次会话CRT
记录一次会话CRT --------------------- su -oracle sqlplus / as sysdba sqlplus username/password 如:普通用户登录 ...
- Android studio 读取properties文件
System.out.println(Thread.currentThread().getContextClassLoader().getResource("").getPath( ...
- 【风马一族_Java】java的一种IDE
IntelliJ IDEA 14 下载地址: IntelliJ IDEA 14 下载 分享几个license: (1) key:IDEA value:61156-YRN2M-5MNCN-NZ8D2-7 ...
- 隐马尔科夫模型及Viterbi算法的应用
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4335810.html 一个例子: 韦小宝使用骰子进行游戏,他有两种骰子一种正常的骰子,还有一 ...
- ADO.NET笔记——调用存储过程
相关知识: 在ADO.NET访问SQL Server时,鼓励使用存储过程取代常规的SQL语句. 存储过程有下列优点: 存储过程中的SQL语句将会经过预先的解析和编译,然后存放在数据库服务器上行.调用的 ...
- Nginx 之并发优化
客户端/服务端 连接数 ulimit -n 100000 nginx 链接数 10240 个 worker_connections 10240;允许打开文件数worker_processes 1;wo ...
- jquery中简易tab切换
<!doctype html> <html> <head> <title>test</title> <meta content=&qu ...
- php出现“syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM”错误的一种情况,及解决方法
PHP中的“syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM”错误,可能是因为美元符号$的误用,看下面一种情况 class Test{ s ...
- GoldenGate 基础架构
一.Goldengate 产品家庭 Goldengate:核心产品 Goldengate Director :现已更名为Goldengate Management Pack,为Goldengate提供 ...
- Windows Server 2008 R2 64bit兼容Chrome浏览器
近日更换系统Windows Server 2008 R2 64bit系统,发现谷歌浏览器插件无法正常运行,终于找到如下解决方案: 打开桌面谷歌浏览器属性,将target目标 C:\Users\Admi ...