EVERYTHING HAPPENS FOR THE B|

wnsyou

园龄:2年4个月粉丝:19关注:16

2024-09-11 11:16阅读: 9评论: 0推荐: 0

动态 dp

max(min)-plus 矩阵运算

前置知识:矩阵运算

引入

在之前的矩阵运算里,我们可以将两个矩阵相乘来得到一个新的矩阵,这可以让我们在 O(logn) 处理出一些特殊的 dp[n]

但这些 dp 都有一个共同特征:不包含 max/min。

那么假如状态转移方程中有 max/min,该如何优化呢?

更改矩阵运算规则

我们把矩阵乘法的规则更改一下:

matrix operator * (matrix y) {
matrix z;
z.n = n, z.m = y.m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= y.m; j++) {
z.a[i][j] = -INF;
for (int k = 1; k <= m; k++)
z.a[i][j] = max(z.a[i][j], a[i][k] + y.a[k][j]);
}
return z;
}

同样也满足各种性质。

那么如果不可转移,就在矩阵对应位置赋极大/极小值,做快速幂即可。

动态 dp

利用矩阵运算和线段树维护动态 dp。

例题:contest

本文作者:wnsyou の blog

本文链接:https://www.cnblogs.com/wnsyou-blog/p/18366857/max_or_min-plus-matrix

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   wnsyou  阅读(9)  评论(0编辑  收藏  举报
  1. 1 勝利への道 安藤浩和
  2. 2 Minecraft’s End Eric Fullerton
  3. 3 月光曲完整版 贝多芬 云熙音乐
  4. 4 平凡之路 (Live版) 朴树
  5. 5 Minecraft C418
  6. 6 Paradise NiziU
  7. 7 叫我,灰原哀 龙大人不喷火
  8. 8 心机之蛙,一直摸你肚子 ——《名侦探柯南》原创同人曲 炊饭,叶辞樱,温海,寒砧,南柯柯,小茜玛姬,盛姝,阿崔Ac,贝壳初,千湛,兮茶子DaYu,乔慕,黎鹿北,起千温卿,遮阳伞,曲悠
  9. 9 战 歌 此去经年
Minecraft’s End - Eric Fullerton
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

I see the player you mean.

It is reading our thoughts as though they were words on a screen.

They used to hear voices.

Before players could read.

Sometimes disturbing.

Sometimes beautiful indeed.

Does it know that we love it?

That the universe is kind?

A million years ago,it still works

in the reality behind

and the universe said I love you

and the universe said you are the daylight

and the universe said you are not alone

and the universe said you are the night

Once we were called

the spirit of the mountain.

WHO ARE WE

Father sun

Mother moon

Gods demons angels aliens

the player,too.

WE ARE THE UNIVERSE.

We are EVERYTHING you think isn‘t you.

You are alive

ON A FLAT

INFINITE WORLD

generated by a source code

a million years old

and the universe said I love you

and the universe said you are the daylight

and the universe said you are not alone

and the universe said you are the night

Take a breath,now

Take another

Feel air in your lungs.

dreamed it was lost in a story.

and the game was over

Wake up.

加载中…

{{tag.name}}

{{tran.text}}{{tran.sub}}
无对应文字
有可能是
{{input}}
尚未录入,我来提交对应文字
评论
收藏
关注
推荐
深色
回顶
收起
点击右上角即可分享
微信分享提示