此题未通过 [ 老帅哥 ] 认证。

ZJ一下:

T1,明显是二分答案+$dij/SPFA$

T2,没看懂题。

T3,打了一个$\Theta(N^2)$暴力。

事实上……

T1,T2死了。

T1中

每次可以向上下左右四个方向走一格,走一格用时1 秒。

你有一个机器,使得每次在上下移动一步时,用时为k 秒。

你确定向上下不可以走么(一定要用机器???)

明明可以向上下左右四个方向走一格,走一格用时1

不管了,语文问题。

最后在作者××巨佬的自动防AK系统的作用下。

47
Miemeng 0

02:58:59
0

02:58:59
30

02:59:00
30

02:59:00

我祝福你,作者

%%%ZZD

nmsl

题解:

T1

一大句话题意:

有一个网格图,有格子不能走,向上下走需要$k$秒,向左右走需要$1$秒,问从$(x1,y1)$到$(x2,y2)$的最短时间为$s$时$k$的值。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#define LF double
#define N 111 using namespace std; const LF eps=1e-5;
int mp[N][N];
int lines,cols;
int stx,sty,fix,fiy;
LF targ,dis[N][N];
bool is_v[N][N];
struct POINT{
int x,y;
double dis;
POINT(){}
POINT(int a,int b,double c):x(a),y(b),dis(c){}
friend bool operator > (const POINT &a,const POINT &b){
return a.dis>b.dis;
}
};
priority_queue<POINT,vector<POINT>,greater<POINT> >q;
inline bool inmp(int x,int y){
return x>=1&&x<=lines&&y>=1&&y<=cols&&mp[x][y]==0;
}
LF check(LF ud){
memset(is_v,0,sizeof is_v);
for(int i=1;i<=lines;i++)
for(int j=1;j<=cols;j++)
dis[i][j]=1e10;
dis[stx][sty]=0;
q.push(POINT(stx,sty,0.0));
while(!q.empty()){
int fx=q.top().x,fy=q.top().y;
// cout<<fx<<" "<<fy<<" "<<mp[fx][fy]<<" "<<dis[fx][fy]<<endl;
q.pop();
if(is_v[fx][fy])continue;
is_v[fx][fy]=1;
if(inmp(fx+1,fy)&&dis[fx+1][fy]>dis[fx][fy]+ud){//puts("A");
dis[fx+1][fy]=dis[fx][fy]+ud;
q.push(POINT(fx+1,fy,dis[fx+1][fy]));
}
if(inmp(fx-1,fy)&&dis[fx-1][fy]>dis[fx][fy]+ud){//puts("B");
dis[fx-1][fy]=dis[fx][fy]+ud;
q.push(POINT(fx-1,fy,dis[fx-1][fy]));
}
if(inmp(fx,fy+1)&&dis[fx][fy+1]>dis[fx][fy]+1.0){//puts("C");
dis[fx][fy+1]=dis[fx][fy]+1.0;
q.push(POINT(fx,fy+1,dis[fx][fy+1]));
}
if(inmp(fx,fy-1)&&dis[fx][fy-1]>dis[fx][fy]+1.0){//puts("D");
dis[fx][fy-1]=dis[fx][fy]+1.0;
q.push(POINT(fx,fy-1,dis[fx][fy-1]));
}
}
return dis[fix][fiy];
}
int main(){
// freopen("1.in" ,"r",stdin);
// freopen("maze.in" ,"r",stdin);\
freopen("maze.out","w",stdout);
scanf("%d%d%d%d%d%d",&lines,&cols,&stx,&sty,&fix,&fiy);
for(int i=1;i<=lines;i++)
for(int j=1;j<=cols;j++)
scanf("%d",&mp[i][j]);
scanf("%lf",&targ);
LF l=0,r=lines*cols;
while(r-l>eps){
LF mid=(l+r)/2;
// cout<<l<<" "<<r<<" "<<check(mid)<<endl;
if(check(mid)>targ) r=mid;
else l=mid;
}
printf("%.3lf\n",l);
// cout<<clock()<<endl;
}

T2

T3

19-10-25-G-悲伤的更多相关文章

  1. 程序员的 Ubuntu 19.10 配置与优化指南

    原文地址:程序员的 Ubuntu 19.10 配置与优化指南 0x00 环境 CPU: Intel Core i9-9900k GPU: GeForce RTX 2070 SUPER RAM: DDR ...

  2. 背水一战 Windows 10 (25) - MVVM: 通过 x:Bind 实现 MVVM(不用 Command)

    [源码下载] 背水一战 Windows 10 (25) - MVVM: 通过 x:Bind 实现 MVVM(不用 Command) 作者:webabcd 介绍背水一战 Windows 10 之 MVV ...

  3. /proc/interrupts 统计2.6.38.8与3.10.25差异

    eth4进,eth5出 linux-3.10.25 67:          2          3          2          3   PCI-MSI-edge     eth468: ...

  4. CentOS安装NodeJS v0.10.25 + Express

    安装必需组件 yum -y install gcc make gcc-c++ openssl-devel wget cd ~wget http://nodejs.org/dist/v0.10.25/n ...

  5. 10.25 正睿停课训练 Day9

    目录 2018.10.25 正睿停课训练 Day9 A 数独(思路 DP) B 红绿灯(最短路Dijkstra) C 轰炸(计算几何 圆并) 考试代码 B C 2018.10.25 正睿停课训练 Da ...

  6. Ubuntu 19.10 发布 | 云原生生态周报 Vol. 24

    作者 | 木苏.进超.冬岛.元毅.心水.衷源 业界要闻 1.云原生编程语言 Pulumi 1.0 pulumi ,一款中立的开源云开发平台,Pulumi 支持多语言.混合云环境.完全可扩展.初期支持 ...

  7. [Linux] 在 Ubuntu 19.10 上开启 SSH 服务并允许远程登录

    在 Ubuntu 19.10 上安装 SSH,并开启服务 0.检查并确认系统当前是否已安装SSH: sudo ps -e | grep ssh 如果只有 ssh-agent 说明 ssh-server ...

  8. [Linux] 树莓派 4B 安装 Ubuntu 19.10 (Eoan Ermine) IOT 版

    硬件:Raspberry Pi 4B系统:Ubuntu 19.10 (Eoan Ermine) for IOT官网:https://ubuntu.com/download/iot/raspberry- ...

  9. Java习题10.25

    Java习题10.25 1. 实际上这道题考查的是两同两小一大原则: 方法名相同,参数类型相同 子类返回类型小于等于父类方法返回类型, 子类抛出异常小于等于父类方法抛出异常, 子类访问权限大于等于父类 ...

  10. Ubuntu 19.10 安装 jupyter

    安装pip3 ubuntu 19.10 已经没有python了,取代的是python3. 执行sudo apt install python3-pip安装pip3 安装jupyter 执行sudo p ...

随机推荐

  1. csps-模拟7980题解

    题面:https://www.cnblogs.com/Juve/articles/11712702.html 树: 我太sb了不知道DROT是1,还在sb找根 记录一个fa[]数组,表示x的祖先中第一 ...

  2. 几个dp的陈年老题

    真 陈年老题 都是基础的dp优化 主要是展现我基础薄弱,菜得抠脚 1.四边形不等式 四边形不等式:w[i][j]+w[i+1][j+1]<=w[i+1][j]+w[i][j+1] 对于f[i][ ...

  3. cookie的设置与销毁

    <?php /* 2个参数设置cookie cookie随着浏览器的关闭,就失效了 ); /* 下面我们让cookir多活一会 3个参数来设置cookie,第3个参数指的就是cookie的声明周 ...

  4. java-day05

    数组概念 是一种容器,能够存放多个数据值 特点 多个数据值类型必须统一 是一种引用数据类型 程序运行时,数组长度不可改变 数组初始化 动态初始化格式 数据类型[] 数组名称 = new 数据类型[数组 ...

  5. 12_springmvc拦截器

    一.定义 Spring Web MVC 的处理器拦截器类似于Servlet 开发中的过滤器Filter,用于对处理器进行预处理和后处理. 二.拦截器定义 实现HandlerInterceptor接口, ...

  6. 腾讯bugly接入插件(CocosCreator)

    下载: plugin-bugly.zip (1.4 MB) 插件开源地址: https://github.com/tidys/CocosCreatorPlugins/tree/master/packa ...

  7. UMP系统架构 Mnesia

  8. 介绍了Apache日志文件每条数据的请意义以及一些实用日志分析命令

    这篇文章主要介绍了apache日志文件每条数据的请意义,以及一些实用日志分析命令,需要的朋友可以参考下(http://wap.0834jl.com) 一.日志分析 如果apache的安装时采用默认的配 ...

  9. LUOGU P2344 奶牛抗议 (树状数组优化dp)

    传送门 解题思路 树状数组优化dp,f[i]表示前i个奶牛的分组的个数,那么很容易得出$f[i]=\sum\limits_{1\leq j\leq i}f[j-1]*(sum[i]\ge sum[j- ...

  10. fiddler报错:creation of the root certificate was not successful 证书安装不成功

    fiddler提示:creation of the root certificate was not successful 证书安装不成功 首先 找到Tools——>Options 在弹出的菜单 ...