ACdreamoj(1105)模拟题

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

. 表示此处为空地

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

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)模拟题,布布扣,bubuko.com

时间: 2024-07-28 19:10:44

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

HDU 4028 The time of a day STL 模拟题

暴力出奇迹.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<queue> #include<set> #include<map> using namespace std; #define ll __int64 #define N 42 ll n,m,ans;

cf428c 模拟题

这题说的是给了 n个数然后又 k次 的交换任意位置的 数字的机会  计算最长的连续子序列的和 这要撸  模拟整个 过程 并不能就是算最长的递增序列 如果只是 找最长的 和序列的 话 会存在 很多问题 在替换的时候 每一个决策 都影响着 下一个决策  这样 存在谁与谁替换 这样的状态有 200!种    那就枚举每个区间这样就可以使得 我们所用替换方法得当  因为在替换中我们进行替换是对不同区间的 操作 比如 在替换序列之内的 数字的时候 其实操作的就是不同的区间 与外面的序列进行替换的时候 操作

TOJ1290 Poker Hands 模拟题

寒假期间抽空做的一道模拟题 难度不算大,把每种牌型分开处理,可以合并的步骤考虑合并. 代码比较丑陋,首次尝试Sport Programming的风格,结果搞了个不伦不类(手动笑哭) 1 #include <algorithm> 2 #include <bitset> 3 #include <cctype> 4 #include <complex> 5 #include <cstdio> 6 #include <cstring> 7 #

hdu 5641 King&#39;s Phone(暴力模拟题)

Problem Description In a military parade, the King sees lots of new things, including an Andriod Phone. He becomes interested in the pattern lock screen. The pattern interface is a 3×3 square lattice, the three points in the first line are labeled as

HDU 2414 Chessboard Dance(模拟题,仅此纪念我的堕落)

题目 模拟题也各种wa,我最近真的堕落了,,,,,智商越来越为负数了!!!!!!!! #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; char mp[10][10]; int d=-1;//0shang,1xia,2zuo,3you int x,y;//weizhi int weizhi(int i,int j) { if(mp[i][j]=='<'){x=

HDU 4930 Fighting the Landlords(扯淡模拟题)

Fighting the Landlords 大意: 斗地主....   分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3. 给你8种组合:1.

锦程网考试由试题从模拟题中批量找出答案,Python

jincin的考试又来了,像往常一样会先有模拟题发下来,而考试题目几乎都在里面原题. 本来是,在考试时,把题目一题一题地在模拟题里搜,但觉得太累了. 于是写了一个Python的脚本批量查找,用到正则,由于不知道行尾是\r还是\n还是\r\n,干脆也用正则,而非split('\r')这么硬板了. 添了颜色,效果不错. Python: 效果: - 锦程网考试由试题从模拟题中批量找出答案,Python,布布扣,bubuko.com

Codeforces 48C The Race 模拟题

题目链接:点击打开链接 题意: 给定n个加油站,一辆车由A点跑到B点,每个100m有一个加油站,每开100m需要10升油. 在每个车站会检查一下油量,若车子若开不到下一个加油站则加x升油. 开始有x升油 下面给出加油的记录. 问下一次加油在哪一站.若答案唯一输出具体哪站. 油箱容量无限 思路: 水模拟.. #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h>

FZU Problem 2034 Password table (简单模拟题)

这种简单题做了好长时间,我是不是有点逗? 地址:http://acm.fzu.edu.cn/problem.php?pid=2034 不解释了,自己看吧,练手的好题 上个代码吧 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #include <stdio.h> #include <string.h> #include <stdlib.h>