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

推荐订阅源

WordPress大学
WordPress大学
Cyberwarzone
Cyberwarzone
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
小众软件
小众软件
Recent Announcements
Recent Announcements
博客园 - 三生石上(FineUI控件)
Security Archives - TechRepublic
Security Archives - TechRepublic
W
WeLiveSecurity
Cloudbric
Cloudbric
博客园 - 司徒正美
美团技术团队
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
PCI Perspectives
PCI Perspectives
宝玉的分享
宝玉的分享
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
Last Week in AI
Last Week in AI
S
Schneier on Security
N
News | PayPal Newsroom
B
Blog RSS Feed
L
LINUX DO - 最新话题
T
Troy Hunt's Blog
S
Secure Thoughts
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
L
Lohrmann on Cybersecurity
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tenable Blog
S
Securelist
L
LangChain Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
I
InfoQ
H
Heimdal Security Blog
Cisco Talos Blog
Cisco Talos Blog
F
Full Disclosure
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
K
Kaspersky official blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
阮一峰的网络日志
阮一峰的网络日志
C
Cisco Blogs

某岛

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 DP 优化练习 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
NOI 2009
2023-02-14 · via 某岛

February 14, 2023

诗人小 G

啊。。我觉得这个还是挺难的。。。

#include <lastweapon/io>
using namespace lastweapon;

const int N = int(1e5) + 9;
long double f[N]; int pre[N];
char str[N][31]; int s[N];
PII Q[N]; int cz, op;
int n,l,p;

long double poww(long double x, int b) {
    long double z = 1;
    while (b) {
        if (b&1) z *= x;
        x *= x; b >>= 1;
    }
    return z;
}


long double calc(int a, int b) {
    return f[a] + poww(abs(s[b]-s[a]-l), p);
}

int left(int a, int b) {
    int l = a, r = n+1;
    while (l < r) {
        int m = (l + r) / 2;
        if (calc(b, m) <= calc(a, m)) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    return l;
}


int main(){

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

    Rush {
        RD(n,l,p);++l;
        REP_1(i, n) s[i] = s[i-1] + strlen(RS(str[i])) + 1;

        cz = 0, op = 0; Q[0] = {0, n+1};

        REP_1(i, n) {
            //f[i] = OO; REP(j, i) if (checkMin(f[i], calc(j, i))) pre[i] = j;

            while (cz < op && Q[cz+1].se <= i) ++cz;
            f[i] = calc(pre[i] = Q[cz].fi, i);
            int j = left(Q[op].fi, i);
            while (cz < op && j <= Q[op].se) j = left(Q[--op].fi, i);

            Q[++op] = {i, j};
        }

        //REP_1(i, n) cout << f[i] << " "; cout << endl;
        //REP_1(i, n) cout << pre[i] << " "; cout << endl;

        if (f[n] > 1e18) puts("Too hard to arrange");
        else {
            printf("%.0Lf\n", f[n]);
            VI I; int x = n; I.PB(x);
            do I.PB(x = pre[x]); while (x);

            DWN(i, SZ(I), 1) {
                FOR(j, I[i]+1, I[i-1]) printf("%s ", str[j]);
                puts(str[I[i-1]]);
            }
        }
        puts("--------------------");
    }
}

Posted by xiaodao
Category: 日常