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

. 表示此处为空地

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

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. Acdreamoj1115(数学思维称号)

    意甲冠军:1,3是完美的数,假定a,b是完美的数,然后,2+a*b+2*a+2*b,结论认为,n无论是完美的数字. 解法:開始仅仅看出来2+a*b+2*a+2*b=(a+2)*(b+2)-2,没推出很 ...

  2. PV操作——生产者和消费者

    首先,先来看几个概念: 同步:协作的过程,比如,多人开发合作. 相互排斥:争抢资源的过程.比如苦逼的大学选课: 临界区:进程中对临界资源实施操作的那段程序: 临界资源:一次仅仅能一个进程使用的资源,比 ...

  3. 答读者问(8):相关Java问题涉及到学习

    近来的,我收到一个研究生朋友的电子邮件,一般内容如下面: 日 (本人微博:http://weibo.com/zhouzxi?topnav=1&wvr=5,我们的聊天号码:245924426.欢 ...

  4. HDU 1228 A + B 浙江大学研究生冠军

    Problem Description 读入两个小于100的正整数A和B,计算A+B. 须要注意的是:A和B的每一位数字由相应的英文单词给出.   Input 測试输入包括若干測试用例,每一个測试用例 ...

  5. [LeetCode290]Word Pattern

    题目: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full ...

  6. Java AIO 入门实例(转)

    Java7 AIO入门实例,首先是服务端实现: 服务端代码 SimpleServer: public class SimpleServer { public SimpleServer(int port ...

  7. MySQL InnoDB数据库备份与还原

    备份 进入cm黑窗口 输入下列命令 mysqldump -u 用户名 -p 数据库名称> c:\11.sql 回车执行 恢复 进入cm黑窗口 输入下列命令 mysql>use dbtest ...

  8. C#设计及其UML(反向工程)

    OOP之C#设计及其UML(反向工程)   现在总结一下C#类关键字(virtual.abstract.override.new.sealed)的使用(以C#代码体现),并再次熟悉一下OOP思想,使用 ...

  9. 深入研究Java类载入机制

    深入研究Java类载入机制   类载入是Java程序运行的第一步,研究类的载入有助于了解JVM运行过程,并指导开发人员採取更有效的措施配合程序运行. 研究类载入机制的第二个目的是让程序能动态的控制类载 ...

  10. 【软件使用技巧】PL/SQL Developer实现双击table询

    二手plsql都知道,在表名默认双击[开展/关闭]. 习惯了MySql Workbench要么Sqlserver Management Studio无法适应其他管理工具. 直接在溶液: Tools - ...