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

. 表示此处为空地

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

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. SDL 简单入门学习

    write by 九天雁翎(JTianLing) -- blog.csdn.net/vagrxie 讨论新闻组及文件 概要 实际学习使用SDL创建窗体,并绘制图形. 前言 今天想要做一个简单的demo ...

  2. Maximal Square 我们都在寻找最高1子矩阵(leeCode)

    Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ret ...

  3. CentOS7卸载KDE桌面(转)

    最初安装centos时选择了安装KDE桌面,打开很卡,没有用到,想卸载,可是试了网上的方法什么yum groupremove kde-desktop 都不奏效,于是只能自己找出KDE的包,然后yum卸 ...

  4. Linux学习笔记——举例说,makefile 多个文件

    0.前言     从学习C语言開始就慢慢開始接触makefile,查阅了非常多的makefile的资料但总感觉没有真正掌握makefile,假设自己动手写一个makefile总认为非常吃力. 所以特意 ...

  5. python遗产

    1.    python类方法的定义: class Animal(): def __init__(self,name): self.name=name; def show(self): print s ...

  6. 设计模式C++达到 1.辛格尔顿

    实现类的单个案件的Singleton模式.该系统有一个类只有一个实例,而本实施例是容易的外部访问.所以容易控制的实例的数量,并且节省系统资源. 单的情况下通常与一些非本地静态对象的使用,对于这些对象, ...

  7. quick-cocos2d-x endToLua 退出会卡住

    问题: 马上赚钱,退出会出现卡住,然后清理,死界面的情况,百思不得其解,昨天在做push的时候,突然发现.在android里面弹出一个退出对话框,点击确定退出,这时候调用endtolua时,有时也会切 ...

  8. 【转】c#实现字符串倒序的n种写法

    其中LINQ写法最为简洁 //string concatenation with for loop public string ReverseA(string text) {     char[] c ...

  9. 左右10g DG中间ORA-19527和ORA-00312错误解决演示示例

    这些天大厦10g DG Windows 2008 R2测试环境,主要明天去给客户端,再建一个生产资源库DG,其中一些发现的问题.特此记录下来 因为将要部署到生产环境.所以考虑在线搭建DG的方案,即不停 ...

  10. BibTex (.bib) 文件的凝视

    1) 将某个參考文献所有去掉,能够去掉前面的『@』 样例 @article{##,    author = {###},    title = {###},    journal = {###},   ...