Good Bye 2016 //智商再次下线,边界爆炸.....

A B很水就略了..

C.又是一次wannafly一样的判断区间的.....  边界设为2000000  正好GG...... fst的时候立马想到上次也是这么wa过的......

所以下次遇到这种题.... 边界还是 写INT_MIN 和  INT_MAX了 

哈哈  写的时候  还是感觉蛮舒服的 

D.每层烟花爆炸后沿与当前方向成45度的方向飞 经过t秒下一层爆炸 ..然后问到过的点的位置

最远的地方是150  等于300×300的图 那么我们 直接放在一个vis标记 

再放一个 剪纸数组 n*8×300×300的mk数组  代表当前的地方烟花沿。。爆炸过没

DFS+剪纸 我们先把方向存起来   然后从最中央的地方开始爆炸....

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <map>
#include <climits>
using namespace std;
typedef long long ll;
const int N = 330;
const int p = 155;
int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = {0, -1, -1, -1, 0, 1, 1, 1};
bool vis[N][N];
bool mk[35][N][N][10];
int n;
int t[N];
void dfs(int deep,int nowx,int nowy,int dir)
{
    if(mk[deep][nowx][nowy][dir]||deep>=n) return ;
    mk[deep][nowx][nowy][dir] = true;
    for(int i=0;i<t[deep];i++)
    {
        nowx+=dx[dir];
        nowy+=dy[dir];
        vis[nowx][nowy] = true;
    }
    dfs(deep+1,nowx,nowy,(dir+1)%8);
    dfs(deep+1,nowx,nowy,(dir-1+8)%8);
    
}
int main()
{
    scanf("%d",&n);
    //t[0] = 0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",t+i);
    }
    dfs(0,p,p,0);
    int ans = 0;
    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)
            ans+=vis[i][j]?1:0;
    cout<<ans<<endl;
    return 0;
}
AC代码

写起来也不是很难.... 当时真的是被吓怕的.......

E.

原文地址:https://www.cnblogs.com/Geek-xiyang/p/6243322.html