惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
人人都是产品经理
人人都是产品经理
H
Heimdal Security Blog
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
雷峰网
雷峰网
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Microsoft Azure Blog
Microsoft Azure Blog
MyScale Blog
MyScale Blog
A
About on SuperTechFans
V2EX - 技术
V2EX - 技术
小众软件
小众软件
博客园 - Franky
博客园 - 司徒正美
P
Privacy International News Feed
爱范儿
爱范儿
U
Unit 42
博客园 - 叶小钗
The Hacker News
The Hacker News
C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Simon Willison's Weblog
Simon Willison's Weblog
N
News and Events Feed by Topic
D
Docker
T
Threatpost
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Help Net Security
L
LINUX DO - 最新话题
Security Latest
Security Latest
T
The Exploit Database - CXSecurity.com
S
SegmentFault 最新的问题
A
Arctic Wolf
Spread Privacy
Spread Privacy

某岛

AtCoder Beginner Contest 409 Luogu P5325. 【模板】Min_25 筛 UOJ #188. 【UR #13】Sanrd AtCoder Beginner Contest 371 AtCoder Beginner Contest 369 RPGMaker 2k3 百科 OneShot 的考古 2024“开创拓芯”游戏创享节的相关记录 CJ 回来后的戒断反应 Luogu P10221. [省选联考 2024] 重塑时光 Luogu P5308 [COCI2018-2019#4] Akvizna wqs 二分 歌唱王国 Lean 相关 BZOJ 3153. Sone1 The 2023 ICPC World Finals Luxor 新巴别塔 Sora 的想象与思考 Facebook Hacker Cup 2023 Round 1 AtCoder Beginner Contest 322 LLaMA 2 相关 HuggingFace AI Game Jam ACL 2023 Trans 相关… Luogu P2053. [SCOI2007] 修车 Luogu P1973. [NOI2011] NOI 嘉年华 Luogu P1933. [NOI2010] 旅行路线 Luogu P1954. [NOI2010] 航空管制 Luogu P2048. [NOI2010] 超级钢琴 Luogu P2046. [NOI2010] 海拔 Luogu P3227. [HNOI2013] 切糕 Luogu P8500. [NOI2022] 冒泡排序 Luogu P3629. [APIO2010] 巡逻 USACO 2018 February Contest, Gold Problem 2. Directory Traversal Luogu P3647. [APIO2014] 连珠线 IZhO 2017. Problem F. Hard route SPOJ TWOPATHS. Two Paths 换根 dp 洪恩电脑 —— 开天辟地 Facebook Hacker Cup 2022 Round 2 Codeforces Round #875 Luogu P5828 边双连通图计数 EC Final 拉格朗日反演定理 Luogu P5827. 点双连通图计数 无标号连通图 AtCoder Beginner Contest 284 Luogu P4708. 画画 Luogu P6295. 有标号 DAG 计数 BZOJ #2863. 愤怒的元首 HDU 3303. Harmony Forever 聊聊《明日方舟 Side Story 孤星》与《崩坏:星穹铁道》 SGU 208. Toral Tickets 后日谈,SHLUG 月度分享(上) 钢琴练习 EasyRPG x ChatGPT ControlNet 相关 The 1st Universal Cup, Stage 4, Ukraine EasyRPG —— Sliding Puzzle The 1st Universal Cup, Stage 3, Poland NOI 2009 TypeDB Forces 2023 Nas 买来做什么… Global Game Jam 2023 参赛纪录 The 1st Universal Cup, Stage 2, Hongkong The 1st Universal Cup, Stage 0, Nanjing Codeforces Round #850 舟游同人游戏 RM2k3 机能增强 —— EasyRPG Player 魔改版 《海之歌》设定与剧本 dfs 序求 lca Codeforces Round #844 P3768 简单的数学题 AtCoder Beginner Contest 281 ChatGPT 相关 AtCoder Grand Contest 059 AtCoder Beginner Contest 280 Codeforces Global Round 24 事实核查,以乌鲁木齐火灾为例 SPOJ MUSKET. Musketeers Pinely Round 1 Note about FTX Permutation ICPC World Final 2021 CodeTON Round 3 Codeforces Round #831 Educational Codeforces Round 138 NovelAI 法术指南 卡农 Educational Codeforces Round 135 Codeforces Round #819 瓦喵之夏 NOI 2022 Luogu P3765 总统选举 Luogu P3369 【模板】普通平衡树 网络国家 旋转卡壳 OFAC Sanctions && Tornado Cash BZOJ 1185. [HNOI2007]最小矩形覆盖 Codeforces Round #814
DP 优化练习
2023-02-14 · via 某岛

Luogu P2513. [HAOI2009]逆序对数列

#include <lastweapon/io>
using namespace lastweapon;

const int N = int(1e3) + 9;
int f[N];
int n, m;

int main(){

#ifndef ONLINE_JUDGE
     //freopen("in.txt", "r", stdin);
#endif

    RD(n, m); f[0] = 1;
    FOR(i, 1, n) {
        DWN_1(j, m, 1) {
            int t = max(0, j-i);
            DWN(k, j, t) f[j] += f[k];
            f[j] %= 10000;
        }
    }
    cout << f[m] << endl;
}
#include <lastweapon/io>
using namespace lastweapon;

const int N = int(1e3) + 9;
int f[N], s[N];
int n, m;

int main(){

#ifndef ONLINE_JUDGE
     //freopen("in.txt", "r", stdin);
#endif

    RD(n, m); f[0] = 1;
    FOR(i, 1, n) {
        REP(j, m) s[j+1] = s[j] + f[j];
        DWN_1(j, m, 1) {
            f[j] += s[j] - s[max(0, j-i)];
            f[j] %= 10000;
        }
    }
    cout << f[m] << endl;
}

Luogu P2511. [HAOI2008]木棍分割

这个暴力反而不太好写。。。对于每个状态,大概需要分别有 best[i][j], ways[i][j] 表示长度为 j 恰好切 i 段,时的最优解和方案数。
但转移的方程里面有 max() 导致非常难以优化。

进一步我们发现 best 是可以直接二分出来的。。。有了最大切痕长度,在考虑 dp 方案数就简化非常多了。。(此时我们在最后的最大切痕一定等于 best。。即使中间允许不满足)

#include <lastweapon/io>
using namespace lastweapon;

const int N = int(5e4) + 9;
int a[N], s[N], lt[N]; int ways[N], sums[N];
int n, m, p, q;

bool ok(int x) {
    int cur = 0, cnt = 0;
    REP_1(i, n) {
        if (cur + a[i] > x) cur = 0, ++cnt;
        cur += a[i];
    }
    return cnt <= m;
}

int get_cut() {
    int l = *max_element(a+1, a+n+1), r = s[n];
    while (l < r) {
        int m = (l + r) / 2;
        if (ok(m)) r = m;
        else l = m + 1;
    }
    return l;
}

int main() {

#ifndef ONLINE_JUDGE
     freopen("in.txt", "r", stdin);
#endif

    MOD = 10007;
    RD(n, m); REP_1(i, n) s[i] = s[i-1] + RD(a[i]);
    int cut = get_cut();

    int l = 0; REP_1(i, n) {
        while (s[i] - s[l] > cut) ++l;
        lt[i] = l;
    }

    REP_1(i, n) if (s[i] <= cut) ways[i] = 1; else break;
    int tot = ways[n];

    REP_1(i, m) {
        REP(j, n) sums[j+1] = sums[j] + ways[j];
        REP_1(j, n) {
            ways[j] = (sums[j] - sums[lt[j]]) % MOD;
            if (ways[j] < 0) ways[j] += MOD;
        }
        tot += ways[n];
    }
    tot %= MOD;
    printf("%d %d\n", cut, int(tot));
}

P3515 [POI2011]Lightning Conductor

#include <lastweapon/io>
using namespace lastweapon;

const int N = int(5e5) + 9;
int a[N];
int n;


int main() {

#ifndef ONLINE_JUDGE
     freopen("in.txt", "r", stdin);
#endif

    RD(n); REP(i, n) RD(a[i]);

    REP(i, n) {
        int z = 0;

        REP(j, n) {
            int t = sqrt(abs(i-j)); if (t*t < abs(i-j)) ++t;
            checkMax(z, (a[j] - a[i]) + t);
        }
        printf("%d\n", z);
    }
}

Posted by xiaodao
Category: 日常