2019南京网络赛 D. Robots(概率DP与拓扑排序)

Cisco Secure ACS 5.8.0.32 安装 + Crack 教程 在ESXi 6.7 上经历过无数次的安装尝试测试了各种兼容版本都没有安装成功,记最后一次安装成功的过程. 阅读详情

题目链接
在做这道题之前看一个简化版:绿豆蛙的归宿
设 F [ x ] F[x] F[x] 表示从 x x x 走到终点所经过的路径的期望长度。若从 x x x 出发有 k k k 条边,分别到达 y 1 , y 2 . . . y k y_1,y_2...y_k y1​,y2​...yk​ ,边长分别为 z 1 , z 2 . . . z k z_1,z_2...z_k z1​,z2​...zk​ ,则根据数学期望的定义和性质,有: F [ x ] = 1 k ∗ ∑ i = 1 k ( F [ y i ] + z i ) F[x]=\frac{1}{k}*\sum_{i=1}^k(F[y_i]+z_i) F[x]=k1​∗i=1∑k​(F[yi​]+zi​)
就可以将边取反然后用拓扑排序解决。

现在这道题在上面这道题的基础上相当于将边长设置为 1 ,然后多了一个每次多走一条边的花费。
每个点到 n n n 点的距离相当于: F d a y [ i ] = 1 d e g [ i ] + 1 ∗ ∑ j = 1 d e g [ i ] ( F d a y [ i ] + 1 ) + 1 d e g [ i ] + 1 ∗ ( F d a y [ i ] + 1 ) F_{day}[i]=\frac{1}{deg[i]+1}*\sum_{j=1}^{deg[i]}(F_{day}[i]+1)+\frac{1}{deg[i]+1}*(F_{day}[i]+1) Fday​[i]=deg[i]+11​∗j=1∑deg[i]​(Fday​[i]+1)+deg[i]+11​∗(Fday​[i]+1)化简之后: F d a y [ i ] = 1 d e g [ i ] ∗ ∑ j = 1 d e g [ i ] F d a y [ i ] + 1 d e g [ i ] + 1 F_{day}[i]=\frac{1}{deg[i]}*\sum_{j=1}^{deg[i]}F_{day}[i]+\frac{1}{deg[i]}+1 Fday​[i]=deg[i]1​∗j=1∑deg[i]​Fday​[i]+deg[i]1​+1
每个点到 n n n 点的花费相当于: F c o s t [ i ] = 1 d e g [ i ] + 1 ∗ ∑ j = 1 d e g [ i ] ( F c o s t [ i ] + F d a y [ i ] ) + 1 d e g [ i ] + 1 ∗ ( F c o s t [ i ] + F d a y [ i ] ) F_{cost}[i]=\frac{1}{deg[i]+1}*\sum_{j=1}^{deg[i]}(F_{cost}[i]+F_{day}[i])+\frac{1}{deg[i]+1}*(F_{cost}[i]+F_{day}[i]) Fcost​[i]=deg[i]+11​∗j=1∑deg[i]​(Fcost​[i]+Fday​[i])+deg[i]+11​∗(Fcost​[i]+Fday​[i])化简后: F c o s t [ i ] = 1 d e g [ i ] ∗ ∑ j = 1 d e g [ i ] F c o s t [ i ] + F d a y [ i ] d e g [ i ] + F d a y [ i ] F_{cost}[i]=\frac{1}{deg[i]}*\sum_{j=1}^{deg[i]}F_{cost}[i]+\frac{F_{day}[i]}{deg[i]}+F_{day}[i] Fcost​[i]=deg[i]1​∗j=1∑deg[i]​Fcost​[i]+deg[i]Fday​[i]​+Fday​[i]
由于我太菜,拓扑排序的版本我写的一直不对,改成 dfs 的写法之后就对了,要记得记忆化,不然会超时。

简化版代码:

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define PI acos(-1.0)
#define INF 0x3f3f3f3f3f3f3f3f
#define P pair<double, int>
#define debug(x) cout << (#x) << ": " << (x) << " "
#define fastio ios::sync_with_stdio(false), cin.tie(0)
const int mod = 1e9 + 7;
const int M = 1000000 + 10;
const int N = 1000000 + 10;

int n, m, a, b;
double c;
vector<P> G[N];
int du[N], deg[N];
double f[N];

signed main()
{
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; i ++) {
        scanf("%d %d %lf", &a, &b, &c);
        G[b].push_back(P{c, a});
        du[a] ++, deg[a] ++;
    }

    queue<int> que;
    que.push(n);
    while(que.size()) {
        int now = que.front();
        que.pop();
        for(int i = 0; i < G[now].size(); i ++) {
            f[G[now][i].second] += (f[now] + G[now][i].first) / deg[G[now][i].second];
            du[G[now][i].second] --;
            if(!du[G[now][i].second]) que.push(G[now][i].second);
        }
    }
    printf("%.2lf\n", f[1]);

    return 0;
}

/*

  Rejoicing in hope, patient in tribulation .

*/

代码:

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define PI acos(-1.0)
#define INF 0x3f3f3f3f3f3f3f3f
#define P pair<int, int>
#define debug(x) cout << (#x) << ": " << (x) << " "
#define fastio ios::sync_with_stdio(false), cin.tie(0)
const int mod = 1e9 + 7;
const int M = 1000000 + 10;
const int N = 400000 + 10;

int t, n, m, a, b;
double f_day[N], f_cost[N];
int deg[N];
vector<int> G[N];

void init()
{
    for(int i = 1; i <= n; ++ i) {
        f_day[i] = f_cost[i] = deg[i] = 0;
        G[i].clear();
    }
}

double dfs_day(int now)
{
    if(now == n) return 0;
    if(f_day[now]) return f_day[now];
    double sum = 0;
    for(int i = 0; i < G[now].size(); ++ i) {
        sum += dfs_day(G[now][i]);
    }
    return f_day[now] = sum / deg[now] + 1 + 1.0 / deg[now];
}

double dfs_cost(int now)
{
    if(now == n) return 0;
    if(f_cost[now]) return f_cost[now];
    double sum = 0;
    for(int i = 0; i < G[now].size(); ++ i) {
        sum += dfs_cost(G[now][i]);
    }
    return f_cost[now] = sum / deg[now] + f_day[now] + f_day[now] / deg[now];
}

signed main()
{
    scanf("%d", &t);
    while(t --) {
        scanf("%d %d", &n, &m);
        init();
        for(int i = 1; i <= m; ++ i) {
            scanf("%d %d", &a, &b);
            G[a].push_back(b);
            deg[a] ++;
        }

        dfs_day(1);
        dfs_cost(1);

        printf("%.2f\n", f_cost[1]);
    }
    return 0;
}

/*

  Rejoicing in hope, patient in tribulation .

*/

Qt思岚激光雷达 Qt关于思岚激光雷达研究示例,本示例采用qt界面开发,可以串口也可以tcp进行设备连接。接收数据进行相关的数据进行绘图, 这种雷达可以用于大屏触摸场景,会场互动触摸场景开发。 #ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QTimer> #include <QWidget> #include "lidarmgr.h" namespace Ui { class MainWidget; } class MainWidget. 阅读详情

相关推荐

STC8G1K08A 实战应用:从配置到功能实现

本文详细介绍了STC8G1K08A单片机的实战应用,从开发环境搭建、GPIO配置、ADC模块使用到定时器中断处理和PWM输出等核心功能。重点讲解了外设模块的协同工作配置技巧,并分享了实际项目开发中的经验教训,帮助开发者快速掌握STC8G1K08A的高效应用。

n4o5p6q7r的博客 391

(2019南京网络赛) D. Robots (概率dp)

传送门 题意:给出一张N个点M条边的有向无环图,1号点为全图唯一的入度为0的点,N号点为全图唯一的出度为0的点 现在你从1号点出发,每单位时间,你有相同的概率 走向相邻节点或原地不动。第 i 单位时间内你的消耗为 i , 询问你走到 N 点的期望消耗。 解:用两次期望递推,第一次dp1[i]求i点到N点的期望时间,第二次dp2[i]求i到N的期望代价,图是个拓扑图,所以我们可以从后往前推。 ...

一只不争气的蒸汽机的博客 753

大数据之数据抽取架构演变过程

而当时我们搭建的Flink集群是基于YARN进行资源管理和调度的,因为YARN中不仅仅包含着FLInk的资源,也有hive,zoozie,hdfs等等的资源,这样容易造成yarn资源的过度使用,容易引起整个底座的cpu以及内存的使用问题,经过排查,主要是由于FLink的使用资源引起的,所以后续就把Flink从整个集群中剥离出来,进行资源的隔离,最后Flink采用了StandAlone HA部署(但是这个目前还是存在问题,后续根据项目进行优化)'topic' = '表名',二、数据抽取架构的演变。

天道酬勤 867

2019南京网络赛D Robots(概率DP+拓扑序)

题目链接 题意: DAG网络中,求从节点1走到节点n的期望的代价,具体代价的定义见题目即可。 思路: 这类概率dp的递推比较经典,很好写出递推式 用两次期望递推,第一次dp1[i]求i点到N点的期望时间,第二次dp2[i]求i到N的期望代价,图是个拓扑图,所以我们可以从后往前推(求DFS求拓扑序就是逆序) 下面借用一下别人的式子。 比赛中没有时间写这个题了,水题花了太...

weixin_30892037的博客 266

用Cadence IC618和TSMC 180nm工艺,从零仿真一个2.4GHz双平衡吉尔伯特混频器

本文详细介绍了使用Cadence IC618和TSMC 180nm工艺从零开始仿真2.4GHz双平衡吉尔伯特混频器的完整流程。涵盖设计环境搭建、原理图设计、仿真配置、性能验证及版图设计等关键步骤,特别适合射频集成电路设计的学习者和实践者参考。通过实操技巧与工艺库结合的工程实践,帮助读者掌握混频器设计的核心技术。

weixin_30328063的博客 550

OpenCV机械臂手眼标定

这篇文章总结了手眼标定的原理,利用OpenCV自带的函数套用参数即可完成眼在手上和眼在手外两种标定。

Q先森的博客 6588

2019南京网络赛 D. Robots (概率dp)

题目链接:https://nanti.jisuanke.com/t/41301 题目大意:一个机器人从一点到n点去,每到一个地方有一个花费,等于机器人已经经过的天数,包含现在这步。 题目思路: 很骚的一个概率dp啊,大概思路是先处理出机器人到一个地方的期望天数,然后再用所求期望天数转移为期望花费。 定义dp1【i】为从i点出发到n点的期望天数。 dp2【...

qq_41645482的博客 366

摩尔线程嵌入式面试题及参考答案(2万字长文)

说一下你对 drm 框架的理解。 DRM(Direct Rendering Manager)是 Linux 系统中用于管理图形显示设备的一个重要框架。 从架构层面来讲,它处于内核空间,主要目的是为用户空间的图形应用程序提供一个统一的接口来访问图形硬件。DRM 包括内核态的驱动模块和用户态的库。内核态的驱动负责和硬件进行交互,比如对显存的管理、硬件寄存器的配置等。用户态的库则方便应用程序利用内核态提供的功能进行图形渲染等操作。 在图形显示的具体流程中,DRM 可以控制显示设备的分辨率、刷

大模型大数据攻城狮的专栏 1229

[ICPC2019 南京网络赛]-D.Robots-拓扑期望递推

纪念逝去的切题能力23333

泉華子的OI足迹 685

《Scratch图形化等级考试(1~4级)历届真题解析》专栏总目录

❤️ 专栏名称:《🌸 专栏介绍:中国电子学会《全国青少年软件编程等级考试》Scratch图形化等级考试(1~4级)历届真题解析。🚀 订阅专栏:原价 99.9,🔥 火爆订阅中 🔥,限时 19.9。订阅后可阅读专栏内所有文章,本专栏持续更新中,欢迎订阅!

人生就是一个不断学习的过程 1万+

【STM32实物】基于STM32设计的智能仓储管理系统

近年来,随着我国仓储发展的和药品需求的不断增多,许多医院都采用药物仓储管理系统。我国的药物仓储产业已经有了长足的发展,仓库的规模不断变大,对仓储的要求也不断增高,药物的存储,识别以及对仓储环境条件的要求成为仓储的重要决策,他们可以根据不同的特点在不同场景中使用。本文详细介绍了一个基于单片机技术的智能仓储管理系统的设计与实现,这个系统可谓是集射频识别(RFID)技术和环境监测传感器于一身,旨在提高仓储操作的自动化和精确度。

嵌入式阿齐Archie 1万+

2019南京网络赛Robots

https://nanti.jisuanke.com/t/41301 dp1[i]表示i到n的期望天数,dp2[i]表示i到n的期望耐力; dp1[u]=sum(dp1[v])/(du[u]+1)+dp1[u]/(du[u]+1)+1; dp2[u]=sum(dp2[v])/(du[u]+1)+dp2[u]/(du[u]+1)+dp1[u]; 化简; #include <ios...

newhonor 290

scp 出现Permission denied错误 解决方法

第一种说辞(来源于网络),说是scp涉及root远程登录,默认是没有打开的,只需要把配置文件中的permit打开即可。最后scp的时候发现还不行,只需要将其scp的服务器用户名 修改为root即可。第二种解决方案,将scp 传输的服务器用户名改为root即可。(这是最基本的,一开始我忽视了这个问题,导致一直scp不了)window系统下,向ubuntu操作系统 scp传输文件。

码农研究僧的博客 6728

2019ICPC南京网络赛 D-Robots(概率dp+拓扑排序)

题目链接 dp1[i] : 从i点到n点的期望天数 dp2[i]:从i点到n点的期望花费 out[i]:i点的出度 i,j之间有边,在i点时,机器人可到达j点,或者不动,概率相同。所以在i点有out[i]+1种选择,+1是代表不管机器人去哪,这一天都要加上。 同理: 因为是从后往前推,该题是有向无环图,所以建反边用拓扑排序。 code: #include<bits/...

qq_40503116的博客 275

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

The Preliminary Contest for ICPC Asia Nanjing 2019 ICPC南京站网络赛 D robots(随机游走概率DP+拓扑排序)

题目链接:https://nanti.jisuanke.com/t/41301 题目大意:有一张有向无环图,你要从入度为0的点走到一个出度为0的点,保证这两种点各只有一个,你可以走到下一个点也可以保持原地不动,每过一天可以走一步,每天都要加上一个值就是已过的天数作为代价,求代价的期望,比如到达一个点需要3天,那么就是1+2+3 题目思路:随机游走模板题?做过类似题目应该这题不成问题...

smilestruggler_Fly To Higher 281

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

2019 ICPC 南京网络赛 D.Robots

2019 ICPC 南京网络赛 D.Robots 题目给出n个点和m条有向边,机器人从1走到n,询问消耗的能量的期望。 如果只是求1到n的期望天数,就是很简单的套路题了,设dp[i]表示从i走到n的期望天数,容易得到dp[i]=p*dp[i]+(1-p)*dp[j]+1,其中p表示原地不动的概率。 比赛的时候求出天数之后就不会做了,没有细想,其实再叠加一曾,再做一次就可以了,设能量消耗是cost[...

yzsjwd的博客 294

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

[概率DP逆推求期望]2019ICPC南京网络赛 D robots

题意:给一个n个点的DAG,每天可以从某点走到其相邻点或者选择停留,第i天的花费是i,问从点1到点n的花费期望。 逆推,所以建反向边然后按拓扑序做。 dp[i]表示第i个点到n的期望天数(就是走几步) ans[i]表示第i个点到n的期望花费 dp[u]+1表示在u停留的情况下到n的天数,sum{dp[v]+1}都是不停留的情况下到n的情况,每种情况出现的概率都是1/(outdegree...

Mr_Alice的博客 753

Robots 2019icpc南京网络赛 DAG概率DP

题目 Description Given a directed graph with no loops which starts at node 1 and ends at node nn. There is a robot who starts at 1, and will go to one of adjacent nodes or stand still with equal probabi...

weixin_44273380的博客 274

Robots(2019 ACM-ICPC 南京赛区网络赛 D)

Problem Description Given a directed graph with no loops which starts at node1and ends at noden. There is a robot who starts at1, and will go to one of adjacent nodes or stand still withequal ...

Alex_McAvoy的博客 633

2019南京网络赛 D Robots 期望dp

题目传送门 题意:给出一幅有向无环图,保证只有1入度为0,n出度为0,求问一个机器人从1出发,每天等概率的走到相邻点或者留在原地,问到达n点的代价。每天的代价都不一样,就是天数(第x天走一步的代价就是x)。 思路:设出度每个点的选择情况为$cnt[i]$,即出度加1.   由于每天的代价和天数有关,所以应该要想到,可以先算出天数的期望。这样就可以得到每个点的代价,再算总的代价期望。...

weixin_30485379的博客 130

2019ICPC南京网络赛 D.Robots(概率dp)

传送门 题意:给出一张N个点M条边的有向无环图,1号点为全图唯一的入度为0的点,N号点为全图唯一的出度为0的点 现在你从1号点出发,每单位时间,你有相同的概率 走向相邻节点或原地不动。第 i 单位时间内你的消耗为 i 询问你走到 N 点的期望消耗 先求出1到n的期望时间,再由此推出期望消耗,第二个转移公式有点迷,本来应该加上从1到n的时间期望,但却加上了从i到n的时间期望。有个博客说累加起来就是...

qq_42944230的博客 222

2019年 ACM/ICPC 亚洲区域赛(南京)网络赛D. Robots(期望dp)

Given a directed graph with no loops which starts at node11and ends at nodenn. There is a robot who starts at11, and will go to one of adjacent nodes or stand still withequal probabilityevery d...

LSD20164388的博客 691

[2019南京网络赛D题]Robots

题目链接 2019.9.2更新 第二天睡醒想了想发现好像搜一遍就可以过,赛时写的花里胡哨的还错了,太菜了QAQ 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn = 3e5 + 10; 5 struct node {...

weixin_30865427的博客 156

2019ICPC南京网络赛 - D. Robots

题意: 给定一个 n 个点、m 条边的有向无环图,现在要从1号结点沿边走向 n 号结点,每天等概率走向某一邻接结点或者停留在原地,每天花费代价为经历的天数,求到 n 号结点时的期望代价。保证只有 1 号结点无入度,只有 n 号结点无出度。(n <= 1e5, m <= 2e5) 链接: https://nanti.jisuanke.com/t/41301 题解: 期望dp,f[u] 表...

weixin_44059127的博客 255

【2019南京ICPC网络赛 D】Robots【DAG上的随机游走】

题意: 给出一个有向无环图,从 111 号点向 nnn 号点前进。每次等概率地转移到后继节点,也有可能留在当前节点。定义每一天的花费是当前走过的天数,即第 iii 天的花费是 iii,求从起点走到终点的总花费。(2≤n≤105,1≤m≤2∗105)(2\leq n\leq 10^5,1\leq m\leq 2*10^5)(2≤n≤105,1≤m≤2∗105) 思路: 令 day[i]day[i]...

lucius-liu.cn 475

【2019ICPC南京网络赛】D. Robots

原题题址 说说实话,这题在没接触过概率dp的时候我不太会做,自学了点概率dp的时候就不太难了。说实话我的题意分析有问题,以为只需要算出期望日期就行了,结果忘了还要算期望花费。 其实两次期望dp就行,而且由于两个转移方式相同,推出一个就行了。 时间期望,dp1[i]dp_{1}[i]dp1​[i]表示到点i的期望时间,根据每个点的概率回推,每次回推时间多1,很容易得到。 dp1[i]=dp1[i]N...

weixin_43751631的博客 348
上一篇: BZOJ-3674 可持久化并查集加强版 (主席树+并查集按秩合并)
下一篇: 牛客练习赛37B 筱玛的排列(字典树 + dfs)
ttoobne
博客等级 码龄9年 13粉丝 59原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值