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

. 表示此处为空地

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

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. iOS Foundation 框架基类

    iOS Foundation 框架基类 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转 ...

  2. 基于lua的网页脚本开发语言cgilua(转)

    这里为大家介绍基于lua脚本实现的网页开发语言,cgilua 介绍 cgilua使用Lua是一个用于创建动态网页的服务器端脚本语言.纯LUA脚本和LUA页(LP)的支持,cgilua.Lua脚本是一个 ...

  3. OCP-1Z0-051-题目解析-第14题

    14. Using the CUSTOMERS table,  you need to generate a report that shows 50% of each credit        a ...

  4. EL与JSTL注意事项汇总

    EL使用表达式(5一个 问题) JSTL使用标签(5问题) 什么是EL.它可以用做? EL全名Expression Language在JSP使用页面 格公式${表达式} 样例${requestScop ...

  5. 静态常量(static final)在class文件里是如何的呢?

    近期写项目遇到一个问题,来回折腾了几次,最终探究清楚了.不废话.上样例. 背景:由于项目小,没有使用配置文件,全部静态常量都放在Config.java里面了 public class Config { ...

  6. 系统如何端子app弄root才干

    最近由于调试USB OTG怪东西.这导致USB端口被占用,这项.虽然我是project版本号,但不能运行adb shell,这是不可能的debug该. 所以,我现在是一个系统终端apk,规划 http ...

  7. dwz 照片回头处理

    我的要求.要选择封面文章,回头一看,实现,查找回头功能bringBack代码中发现的,它们朝着input 标签处理,所以img总是标签不能显示,这么dwz源所做的更改,于dwz.databases.j ...

  8. TestNg显示器(一个)-----监听器,类型和配置使用---另外META-INF详细解释

    原创文章,版权所有所有.转载,归因:http://blog.csdn.net/wanghantong/article/details/40404939 TestNg提供了听众和拦截多种接口开发我们自己 ...

  9. Swift1_关闭

    // main.swift // swift1_关闭 // Created by beyond on 15/6/12. // Copyright (c) 2015年 beyond.com All ri ...

  10. 声明式编程思想和EEPlat

    声明式编程定义 声明式编程(英语:Declarativeprogramming)它是一种编程范式.程相对立.它描写叙述目目标性质,让计算机明白目标,而非流程. 声明式编程不用告诉电脑问题领域.从而避免 ...