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

推荐订阅源

T
Threatpost
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
J
Java Code Geeks
博客园_首页
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
Intezer
P
Palo Alto Networks Blog
V
Vulnerabilities – Threatpost
雷峰网
雷峰网
O
OpenAI News
SecWiki News
SecWiki News
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
N
News | PayPal Newsroom
Project Zero
Project Zero
Forbes - Security
Forbes - Security
IT之家
IT之家
A
Arctic Wolf
WordPress大学
WordPress大学
Jina AI
Jina AI
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
博客园 - 聂微东
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
Cloudbric
Cloudbric
G
GRAHAM CLULEY
博客园 - 叶小钗
H
Hacker News: Front Page
腾讯CDC
量子位
Help Net Security
Help Net Security
人人都是产品经理
人人都是产品经理
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
爱范儿
爱范儿
L
Lohrmann on Cybersecurity
Hacker News - Newest:
Hacker News - Newest: "LLM"
Recorded Future
Recorded Future
C
CERT Recently Published Vulnerability Notes

某岛

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 洪恩电脑 —— 开天辟地 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 优化练习 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
Facebook Hacker Cup 2022 Round 2
2023-05-29 · via 某岛

Problem A. Perfectly Balanced

题意:给定一个字符串,每次询问一个子串,问是否是几乎平衡的。
几乎平衡的定义是,从子串中删除一个字符后,长度为偶数,且前半段中每个字符的出现次数与后半段相等。

A1 中字符集来自小写字符。A2 中字符集来自任意 int。

分析:再考虑弱化,如果字符集只有 {0, 1},那么我们只要先判断下长度是否为奇数,然后枚举一下删哪个位置,然后树状数组比较一下两段 1 的个数是否一样即可。

再考虑如何不枚举删哪个位置,哪么就讨论从哪边删,然后看两边的 diff 是否是一即可。设 S(l, r) 表示 [l, r) 这个区间里 1 出现的次数,那么就是比较一下

  • S(ml, r) – S(l, ml) = 1 或者
  • S(l, mr) – S(mr, r) = 1。

因此对于 A1,我们只要开 25 棵树状数组就能通过。对于字符集任意的情况,我们把所有数字映射成一个随机 uint,然后看 diff 是否恰好是某个字符的映射即可。代码反而比 A1 更简单。

#include <lastweapon/bitwise>
#include <lastweapon/fenwicktree>
#include <bits/stdc++.h>

using namespace lastweapon;

mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<uint64_t> rnd(0, ULLONG_MAX);

const int N = int(1e6) + 9;

map<int, uLL> H;
set<uLL> inHash;
uLL h(int x) {
    if (!CTN(H, x)) inHash.insert(H[x] = rnd(gen));
    return H[x];
}

fenwick_tree<uLL> T;
int a[N];
int n;

int f(int l, int r) {
    if ((r-l)&1) return 0;
    int m = (l+r)/2;
    uLL L = T.sum(l), R = T.sum(r+1), ML = T.sum(m), MR = T.sum(m+1);
    return CTN(inHash, (MR-L)-(R-MR)) || CTN(inHash, (R-ML)-(ML-L));
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    Rush {
        printf("Case #%d: ", ++Case);
        H.clear(); inHash.clear();

        RD(n); T = fenwick_tree<uLL>(n+1);
        REP_1(i, n) T.add(i, h(RD(a[i])));

        int z = 0; Rush {
            int cmd, l, r; RD(cmd, l, r);
            if (cmd == 1) {
                T.add(l, h(r) - h(a[l]));
                a[l] = r;
            } else {
                z += f(l, r);
            }
        }
        printf("%d\n", z);
    }
}

Problem B. Balance Sheet

我们把 day 看成点,client 看成边,那么显然是 dag dp。
对于对于 top K 只要用 multiset 记录 dp 值即可。

const int N = int(1e6) + 9;

typedef pair<pair<int, int>, int> rec;

multiset<LL> z;

map<int, multiset<LL> > c, d;

vector<rec> e;
int a[N],b[N],x[N],y[N];

int n, k;

void fix(multiset<LL>& x) {
    while (x.size() > k) x.erase(x.begin());
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("balance_sheet_input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    Rush {
        printf("Case #%d: ", ++Case);
        z.clear(); RD(n, k);

        c.clear(); d.clear(); e.clear();
        REP_1(i, n) {
            RD(a[i],b[i],x[i],y[i]);
            e.PB({{a[i], x[i]}, -i});
            e.PB({{b[i], y[i]}, i});
        }
        SRT(e);

        for (auto& t: e) {
            if (t.se < 0) { // buy
                int id = -t.se;
                c[id].insert(0);
                for (auto i: d[a[id]]) {
                    c[id].insert(i + x[id]);
                    fix(c[id]);
                }
                for (auto i: c[id]) {
                    z.insert(i); fix(z);
                }

            } else { // sell
                int id = t.se;
                for (auto i : c[id]) {
                    d[b[id]].insert(i - y[id]);
                    fix(d[b[id]]);
                }
            }
        }

        Int zz = 0; for (auto& t: z) zz += Int(t);
        cout << zz <<endl;
    }

}

Problem C. Balance Scale

n 袋饼干,第 i 待里有 C_i 块重 W_i 的饼干。
从所有的饼干中任取 k 个,问其中最重的一块饼干(如果有多个,任取其一)来自第一袋的概率。

Problem D. Work-Life Balance

题意:给定长度为 n 的序列 {Ai},支持 m 次单点修改,问每次修改后至少多少次 swap 操作,可以让序列的一个给定的前缀和等于剩下部分的后缀和。

  • D1 中 Ai ∈ {1,2,3},可以交换任意位置。
  • D2 中 Ai ∈ {1,2},只可以交换相邻位置。

分析:D1 的情况显然可以贪心。

Posted by xiaodao
Category: 日常