P2895 [USACO08FEB]流星雨Meteor Shower

给每个点标记一下能够走的最迟时间,蓝后bfs处理一下

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<queue>
#define re register
using namespace std;
void read(int &x){
char c=getchar();x=;
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=(x<<)+(x<<)+(c^),c=getchar();
}
int min(int a,int b){return a<b?a:b;}
#define N 310
const int d1[]={,,-,,};
const int d2[]={,,,-,};
struct node{int x,y,t;}a;
queue <node> h;
int m,tp=,ans,dan[N][N],win; bool vis[N][N];
int main(){
memset(dan,,sizeof(dan)); int inf=dan[][];
read(m);
for(re int i=;i<=m;++i){
read(a.x);read(a.y);read(a.t);
++a.x; ++a.y;
dan[a.x][a.y]=min(dan[a.x][a.y],a.t);
dan[a.x][a.y+]=min(dan[a.x][a.y+],a.t);
dan[a.x][a.y-]=min(dan[a.x][a.y-],a.t);
dan[a.x+][a.y]=min(dan[a.x+][a.y],a.t);
dan[a.x-][a.y]=min(dan[a.x-][a.y],a.t);
}//处理每个点能走的最迟时间
h.push((node){,,}); vis[][]=;
if(dan[][]==inf) win=,ans=;
while(!h.empty()&&!win){
node u=h.front(); h.pop();
for(re int i=;i<&&!win;++i){
int r1=u.x+d1[i],r2=u.y+d2[i];
if(r1<||r2<||r1>=N||r2>=N) continue;
if(vis[r1][r2]||dan[r1][r2]<=u.t+) continue;
if(dan[r1][r2]==inf) win=,ans=u.t+;
else h.push((node){r1,r2,u.t+}),vis[r1][r2]=;
}
}win ? printf("%d",ans):printf("-1");
return ;
}

bzoj1611 / P2895 [USACO08FEB]流星雨Meteor Shower的更多相关文章

  1. 洛谷—— P2895 [USACO08FEB]流星雨Meteor Shower

    P2895 [USACO08FEB]流星雨Meteor Shower 题目描述 Bessie hears that an extraordinary meteor shower is coming; ...

  2. 洛谷P2895 [USACO08FEB]流星雨Meteor Shower

    题目描述 Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will ...

  3. 洛谷 P2895 [USACO08FEB]流星雨Meteor Shower

    题目描述 Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will ...

  4. 洛谷 P2895 [USACO08FEB]流星雨Meteor Shower 解题报告

    一起来看流星雨吧(话说我还没看到过流星雨呢) 题目 Problem 小A则听说另一个骇人听闻的消息: 一场流星雨即将袭击整个霸中,由于流星体积过大,它们无法在撞击到地面前燃烧殆尽,届时将会对它撞到的一 ...

  5. P2895 [USACO08FEB]流星雨Meteor Shower

    传送门 预处理出每个位置最早被摧毁的时间,在此之前都可以走 直接dfs加个记忆化和最优性剪枝就好了 一定要注意流星的边界,如果波及到负数坐标的位置不要去考虑会RE 一定要考虑流星砸到边界的情况 如 ( ...

  6. ACM Meteor Shower

    贝茜听到一场非同寻常的流星雨( meteor shower)即将来临;有报道称这些流星将撞击地球并摧毁它们所击中的任何东西.为了安全起见(Anxious for her safety), ,她发誓(v ...

  7. BZOJ1611: [Usaco2008 Feb]Meteor Shower流星雨

    1611: [Usaco2008 Feb]Meteor Shower流星雨 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 904  Solved: 393 ...

  8. POJ 3669 Meteor Shower(流星雨)

    POJ 3669 Meteor Shower(流星雨) Time Limit: 1000MS    Memory Limit: 65536K Description 题目描述 Bessie hears ...

  9. BZOJ 1611: [Usaco2008 Feb]Meteor Shower流星雨

    1611: [Usaco2008 Feb]Meteor Shower流星雨 Description 去年偶们湖南遭受N年不遇到冰冻灾害,现在芙蓉哥哥则听说另一个骇人听闻的消息: 一场流星雨即将袭击整个 ...

随机推荐

  1. 为什么在js当中没有var就是全局变量

    因为,在js中,如果某个变量没有var声明,会自动移到上一层作用域中去找这个变量的声明语句,如果找到,就是用,如果没找到, 就继续向上寻找,一直查找到全局作用域为止,如果全局中仍然没有这个变量的声明语 ...

  2. Android 使用线性布局LinearLayout和Button实现一个点红块游戏

    这个游戏的功能类似打地鼠. 项目地址:https://github.com/moonlightpoet/RedBlock 程序下载试玩地址:https://github.com/moonlightpo ...

  3. spring AOP底层原理实现——jdk动态代理

    spring AOP底层原理实现——jdk动态代理

  4. 【死磕jeestie源码】类型后面三个点(String...)和数组(String[])的区别

    类型后面三个点(String...),是从Java 5开始,Java语言对方法参数支持一种新写法,叫可变长度参数列表,其语法就是类型后跟...,表示此处接受的参数为0到多个Object类型的对象,或者 ...

  5. 《转》python学习(6)序列类型-字符串

    转自 http://www.cnblogs.com/BeginMan/archive/2013/06/08/3125502.html 二.序列类型 包含字符串.列表.元祖.模式都一样,举一反三即可.如 ...

  6. Vscode 修改为中文语言

    1 官网下载最新版的vscode : https://code.visualstudio.com/Download 2 安装之后, 按键 F1  搜索框 输入 language   选择 config ...

  7. ubuntu 信使(iptux) 创建桌面快捷方式

    $ sudo ln -s /usr/bin/iptux ~/桌面/iptux.ln

  8. 常用的jq插件

    1.时间版翻转 FlipClock-master 2.整屏切换  fullpage 3.轮播图 swiper 4.滚动条样式 mCustomScrollbar 5.过滤和排序布局插件 Isotope. ...

  9. c# SQL Server数据库操作-数据适配器类:SqlDataAdapter

    SqlDataAdapter类主要在MSSQL与DataSet之间执行数据传输工具,本节将介绍如何使用SqlDataAdapter类来填充DataSet和MSSQL执行新增.修改..删除等操作. 功能 ...

  10. 【Android】eclipse打不开的解决办法和“Jar mismatch! Fix your dependencies”的解决

    JDK1.7能用,cmd下输入java,javac,java -version,javaw配置和环境都没问题的话,有可能是工作空间的问题,就是一般在D盘下的workspace..那个文件夹,删除了,再 ...