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

. 表示此处为空地

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

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. android AlarmManager采用

    Android的闹钟实现机制非常easy, 仅仅须要调用AlarmManager.Set()方法将闹钟设置提交给系统,当闹钟时间到后,系统会依照我们的设定发送指定的广播消息.我们写一个广播去接收消息做 ...

  2. PHP情人:p十几天来学习hp第一天

    我这里是暂时的 Apache web server 和 MY SQL 如WEB,在php-4.3.3下的环境做的程序.当然要简单的构建和訪问查看数据库 PHPMYADMIN 不可少.  以下简介一下P ...

  3. 【Android基础】listview控件的使用(4)-----自定义布局的listview的使用

    前面我介绍了listview控件的不同用法,但是这些用法在实际的开发项目中是不足以满足需求的,因为前面的几种用法只能简单的显示文本信息,而且布局都比较单一,很难做出复杂的结果,在实际的开发项目中,90 ...

  4. yum 安装时错误 Errno 14 Couldn't resolve host 解决办法(转)

    在安装mlocate的时候发现一直报错,错误内容大致如下 Downloading Packages:http://mirrors.163.com/centos/6.5/os/i386/Packages ...

  5. yate.conf

    但档案.粘贴下面的例子.不解释!除去非常灵活!只保留sip电话! [general] ; General settings for the operation of Yate ; modload: b ...

  6. linux shell中间$0,$?,$!和&lt;&lt;&#39;END&#39;

    变量说明: $$ Shell自己PID(ProcessID) $! Shell背景上次执行Process的PID $? 最后执行的命令结束码(回报值) $- 使用Set命令设定的Flag一览 $* 全 ...

  7. ios说说自己的计划是什么样的发展论坛

    ios发展论坛在显示 iOS 5 在,主界面包含以下内置的应用程序: 信息.日历.照片.      YouTube.股市.地图(AGPS辅助的Google地图).天气.时间.计算机.备忘录.系统设置. ...

  8. 更改IOS于UISearchBar撤消button底、搜索输入文本框背景中的内容和UISearchBar底

    转载请标明出处:http://blog.csdn.net/android_ls/article/details/39993433 測试的手机IOS系统版本为:6.1.3,实现过程例如以下: 1.加入U ...

  9. 微通道产品经理Grover采访:美国的微通道设计

    "'哥'在中国是一种尊称吗?哈哈.我们平时都叫张小龙'龙哥'." "是的.Dan哥,当你认为某个人牛逼的时候,你就能够叫他'哥'." 我对于Dan Grover ...

  10. .ARM.exidx

    简介: `.ARM.exidx` is the section containing information for unwinding the stack. If your C program ha ...