题意:射一次激光最多能够攻击到几个敌人(因为激光非常强大,能够在击中敌人后穿过它,而瑶瑶自己的坦克因为有特殊装置,所以不会被激光击中。激光也会直接穿过它)

. 表示此处为空地

* 表示此处为障碍(激光不可穿过。激光路径打到障碍时就结束)

T代表瑶瑶的坦克位置

E代表敌人

/ 代表按 左下-右上 放置的镜子

\ 代表按 左上-右下 放置的镜子

解法:模拟题。因为位置过多。

所以不能用递归模拟。要注意环的推断。还有射击过的敌人要打上标记。

wa了n发,最后发现是=写成了==,真的非常不应该。

代码:

/******************************************************
* @author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <string.h>
//freopen ("in.txt" , "r" , stdin);
using namespace std; #define eps 1e-8
#define zero(_) (abs(_)<=eps)
const double pi=acos(-1.0);
typedef unsigned long long LL;
const int Max=2010;
const int INF=1e9+7; char s[Max][Max];
char s2[Max][Max];
int n,m;
int sx,sy;
int toolx,tooly;
bool en()
{
return !(toolx>=0&&toolx<n&&tooly>=0&&tooly<m&&s[toolx][tooly]!='*');
}
int to=0;
int make(int t)
{
int ans=0;
while(1)
{
if(t==1)
{
toolx-=1;
if(en())
break;
if(s[toolx][tooly]=='T'&&t==to)
break;
if(s[toolx][tooly]=='\\')
t=4;
if(s[toolx][tooly]=='/')
t=2;
if(s[toolx][tooly]=='.'||s[toolx][tooly]=='T')
t=t;
if(s[toolx][tooly]=='E')
{
s[toolx][tooly]='.';
ans++;
t=t;
}
continue;
}
if(t==2)
{
tooly+=1;
if(en())
break;
if(s[toolx][tooly]=='T'&&t==to)
break;
if(s[toolx][tooly]=='\\')
t=3;
if(s[toolx][tooly]=='/')
t=1;
if(s[toolx][tooly]=='.'||s[toolx][tooly]=='T')
t=t;
if(s[toolx][tooly]=='E')
{
s[toolx][tooly]='.';
ans++;
t=t;
}
continue;
}
if(t==3)
{
toolx+=1;
if(en())
break;
if(s[toolx][tooly]=='T'&&t==to)
break;
if(s[toolx][tooly]=='\\')
t=2;
if(s[toolx][tooly]=='/')
t=4;
if(s[toolx][tooly]=='.'||s[toolx][tooly]=='T')
{
t=t;
}
if(s[toolx][tooly]=='E')
{
s[toolx][tooly]='.';//cout<<"fd"<<ans<<endl;;
ans++;
t=t;
}
continue;
}
if(t==4)
{
tooly-=1;
if(en())
break;
if(s[toolx][tooly]=='T'&&t==to)
break;
if(s[toolx][tooly]=='\\')
t=1;
if(s[toolx][tooly]=='/')
t=3;
if(s[toolx][tooly]=='.'||s[toolx][tooly]=='T')
t=t;
if(s[toolx][tooly]=='E')
{
s[toolx][tooly]='.';
ans++;
t=t;
}
continue;
}
}
return ans;
}
void init()
{
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
s[i][j]=s2[i][j];
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=0; i<n; i++)
{
scanf("%s",s[i]);
for(int j=0; j<m; j++)
if(s[i][j]=='T')
{
sx=i,sy=j;
}
}
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
s2[i][j]=s[i][j];
toolx=sx,tooly=sy;
to=1;
int ans=make(1); init(); toolx=sx,tooly=sy;
to=2;
int tool=make(2);
ans=max(ans,tool); init(); toolx=sx,tooly=sy;
to=3;
tool=make(3);
ans=max(ans,tool); init(); toolx=sx,tooly=sy;
to=4;
tool=make(4);
ans=max(ans,tool); cout<<ans<<endl;
return 0;
}
/*
4 4
*E\E
T*E*
E/\*
\E/*
*/

版权声明:本文博客原创文章,博客,未经同意,不得转载。

ACdreamoj(1105)模拟题的更多相关文章

  1. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  2. poj 1888 Crossword Answers 模拟题

    Crossword Answers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 869   Accepted: 405 D ...

  3. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  4. sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)

    The Android University ACM Team Selection Contest Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里 ...

  5. 全国信息学奥林匹克联赛 ( NOIP2014) 复赛 模拟题 Day1 长乐一中

    题目名称 正确答案  序列问题 长途旅行 英文名称 answer sequence travel 输入文件名 answer.in sequence.in travel.in 输出文件名 answer. ...

  6. UVALive 4222 Dance 模拟题

    Dance 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pag ...

  7. cdoj 25 点球大战(penalty) 模拟题

    点球大战(penalty) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/2 ...

  8. Educational Codeforces Round 2 A. Extract Numbers 模拟题

    A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...

  9. URAL 2046 A - The First Day at School 模拟题

    A - The First Day at SchoolTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudg ...

随机推荐

  1. Docker镜像与容器命令(转)

    Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机).bare metal. ...

  2. Heibernate 入门笔记(一)---第一个demo

    最近在学heibernate,是看马士兵老师的视频学的,在这里总结一下,做点笔记.关于heibernate的优点,大家可以在网上 百度,这里不做赘述,直接讲怎么使用heibernate 步骤一:新建项 ...

  3. 解决iOS app集成共享QQ场地,微信的朋友,朋友等功能圈,不能采用苹果公司的审计问题

    最近提交的应用程序App Store时刻,由于App综合QQ登录.份额QQ场地.微信等功能.被拒绝.很郁闷:在最佳.想想办法,这个问题是可以解决. 当共享平台列表显示.根据推断当前设备被安装在一节Ap ...

  4. air mobile andriod ios 页面加载控件

    通过最近的研究flex 书写android .ios申请书,我们遇到了一个问题加载页面,我们用flex sdk 12,air 15 无级似android ListView寻呼模块.所以,我和我的同事们 ...

  5. 乐在其中设计模式(C#) - 外观模式(Facade Pattern)

    原文:乐在其中设计模式(C#) - 外观模式(Facade Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 外观模式(Facade Pattern) 作者:webabcd 介绍 ...

  6. 乐在其中设计模式(C#) - 适配器模式(Adapter Pattern)

    原文:乐在其中设计模式(C#) - 适配器模式(Adapter Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 适配器模式(Adapter Pattern) 作者:webabc ...

  7. 返璞归真 asp.net mvc (11) - asp.net mvc 4.0 新特性之自宿主 Web API, 在 WebForm 中提供 Web API, 通过 Web API 上传文件, .net 4.5 带来的更方便的异步操作

    原文:返璞归真 asp.net mvc (11) - asp.net mvc 4.0 新特性之自宿主 Web API, 在 WebForm 中提供 Web API, 通过 Web API 上传文件, ...

  8. js运动动画

    原文:js运动动画 今天简单的学了一下js运动动画,再此感谢慕课网的这位老师http://www.imooc.com/view/167,讲的很不错. 下面是我整理出来的结果. 知识点一:速度动画. 1 ...

  9. jconsole 连接 eclipse启动项

    eclipse 启动java项目默认情况下不开启jmx远程观看,假设需要看看内存使用情况对项目执行的线程等信息,能eclipse添加启动参数: -Dcom.sun.management.jmxremo ...

  10. Linux课程_系统配置和日常维护

    1.设置命令输入提示格公式:"username:当前文件夹$" 2.设置命令输入提示行格式为:"当前系统时间-用户#"(提示:Shell将通过反引號" ...