随笔分类 -  题解

摘要:线段树 SP1716 GSS3 - Can you answer these queries III SP1043 GSS1 - Can you answer these queries I SP2713 GSS4 - Can you answer these queries IV SP2916 G 阅读全文
posted @ 2022-10-25 11:18 azzc 阅读(52) 评论(0) 推荐(0)
摘要:####P1494 [国家集训队] 小 Z 的袜子 莫队模板 点击查看代码 #include <math.h> #include <stdio.h> #include <string.h> #include <algorithm> const int N = 50005; typedef long 阅读全文
posted @ 2022-10-24 21:18 azzc 阅读(49) 评论(0) 推荐(0)
摘要:Q4.2.2.2. 求组合数·土 考虑 $\bmod p^k$ 的情况 递归计算阶乘,由于要计算逆元,需要除掉所有p的倍数 将阶乘中所有p的倍数拿出来, 递归计算... 点击查看代码 #include <iostream> #include <stdio.h> #include <string.h> 阅读全文
posted @ 2022-10-24 20:58 azzc 阅读(94) 评论(0) 推荐(0)
摘要:P5490 【模板】扫描线 点击查看代码 // 扫描线模板%%% #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <utility> #include <array> # 阅读全文
posted @ 2022-10-24 16:49 azzc 阅读(63) 评论(0) 推荐(0)
摘要:博弈 ###P2575 高手过招 点击查看代码 // 转化为 n 个有向图游戏 #include <stdio.h> #include <string.h> #include <unordered_set> int n, m, T, sg[1 << 20], st[1 << 20], res, st 阅读全文
posted @ 2022-10-24 10:24 azzc 阅读(41) 评论(0) 推荐(0)
摘要:#◉ ABC274 F - Fishing 枚举作为左端点的鱼 每条鱼有一个在这个区间中的时间段 计算出与长度为 a 的区间有交集的时间的区间的权值的最大值 时间的区间(离散化->)差分->每一段的权值的最大值 点击查看代码 Source Code Copy Copy #include <map> 阅读全文
posted @ 2022-10-24 10:02 azzc 阅读(50) 评论(0) 推荐(0)
摘要:P2482 [SDOI2010] 猪国杀 AC于2022年8月9日,代码写了一个晚上 点击查看代码 #include <stdio.h> #include <string.h> const int N = 15, M = 2005; struct Pig { char type; // 类型 boo 阅读全文
posted @ 2022-10-16 14:34 azzc 阅读(55) 评论(0) 推荐(0)
摘要:数位DP 「一本通 5.3 例 1」Amount of Degrees 先将这个数化为 $B$ 进制 从高位向低位枚举: 设当前为第 i 位 这一位贡献为 从高位到第 i+1 位 都是原来的书的前若干位, 第 i 位小于原数的第 i 位且满足题目的条件, 低位到第 i-1 位 任意 (最后一位的贡献 阅读全文
posted @ 2022-10-14 21:05 azzc 阅读(66) 评论(0) 推荐(0)
摘要:1. Public NOIP Round #1 (Div. 1, 提高 2022-09-10 14:00:00) A. 斜二等轴测图 就是个大模拟:将整个图形分为三个部分即可,简单计算亿下就可以了 点击查看代码丑爆了 #include <stdio.h> #include <string.h> ch 阅读全文
posted @ 2022-10-14 15:49 azzc 阅读(164) 评论(0) 推荐(0)
摘要:P6076 JSOI2015染色问题 也是BZOJ4497 容斥原理: 将条件容斥 首先,去掉“至少只用一种颜色”这个条件: 设 f[i]表示用至多 i 种颜色, 每行每列都染色的格子的方案数 则答案为 $\sum\limits_{i=0}^{c}(-1)^iC_c^if_{c-i}$ (i为必须忽 阅读全文
posted @ 2022-10-13 19:02 azzc 阅读(81) 评论(0) 推荐(0)
摘要:P2279 HNOI2003消防局的设立 设 f[u][0] 表示将 u 的子树 和 u的二级祖先都被覆盖 的最小代价 设 f[u][1] 表示将 u 的子树 和 u的一级祖先都被覆盖 的最小代价 设 f[u][2] 表示将 u 的子树 覆盖 的最小代价 设 f[u][3] 表示将 u 的一级儿子覆 阅读全文
posted @ 2022-10-13 16:30 azzc 阅读(40) 评论(0) 推荐(0)
摘要:P2467 SDOI2010地精部落 称满足条件的序列为"波动序列" 性质1: 如果一个波动序列中 i 和 i+1 不相邻, 则交换这两个数后仍然是波动序列 性质2: 将一个波动序列反转, 翻转后仍然是波动序列 设 f[i][j] 表示由 1~i 的数构成的波动序列, 第一个数为 j 且为山峰的方案 阅读全文
posted @ 2022-10-13 14:56 azzc 阅读(64) 评论(0) 推荐(0)
摘要:CF1107E Vasya and Binary String 先复习这两题: P4170涂色 略 P2135方块消除 f[l][r][t]表示将 [l,r] 和 (r,n]中颜色=a[r]的前t个 的消掉的最大收益(最后若干个a[r]颜色已经连续) 消掉后面的: f[l][r][t]<-f[l][ 阅读全文
posted @ 2022-10-13 12:19 azzc 阅读(34) 评论(0) 推荐(0)
摘要:noip十连测day4T2-零(Zero) 题目描述 完全无向图是指任意一对顶点间都有边连接的简单无向图,n 个结点的完全无向图有 M=n(n−1)/2 条边。 如果一个 n 个结点的带权完全无向图,M 条边的权值分别是 [1,M] 这 M 个整数(即任意两条边权值不同,任意一个权值仅属于一条边), 阅读全文
posted @ 2022-10-12 19:12 azzc 阅读(357) 评论(0) 推荐(0)
摘要:T1 图计数 40/100pts (根号分类讨论+整数分拆) 用$m$种颜色染一个n个点的每个联通块的图,求方案数 设有 ans 种这样的图,则答案为 $m^{ans}$ 只需找出有多少种这样的图即可:发现这是个整数分拆问题 ans 为将 $n$ 拆为若干正整数的方案数 朴素DP:$O(n^2)$ 阅读全文
posted @ 2022-10-11 18:00 azzc 阅读(57) 评论(0) 推荐(0)
摘要:P6185 序列 对于操作2连边: 一个连通块中可以任意操作, 只需保证和不变: 可以用并查集将其缩点 然后对于操作1连边: 如果这个图是二分图, 则要求两部分相同; 否则只需保证总和奇偶性相同 点击查看代码 #include <stdio.h> #include <string.h> const 阅读全文
posted @ 2022-10-11 11:42 azzc 阅读(65) 评论(0) 推荐(0)
摘要:CSP-S 2021廊桥分配 点击查看代码 #include <queue> #include <utility> #include <stdio.h> #include <string.h> #include <algorithm> const int N = 1e5 + 5; typedef s 阅读全文
posted @ 2022-10-10 12:33 azzc 阅读(56) 评论(0) 推荐(0)
摘要:[BalticOI 2014 Day1Three Friends] P6739 直接枚举断点,通过分类讨论找到候选值(不包含断点的半个字符串) 使用字符串的Hash(指可以$O(1)$查询区间Hash值的Hash)判断这个字符串是否满足条件 点击查看代码 #include <stdio.h> #in 阅读全文
posted @ 2022-10-09 20:00 azzc 阅读(45) 评论(0) 推荐(0)
摘要:P5017 NOIP2018普及组 摆渡车 点击查看代码 #include <stdio.h> // 做法:设f[i]为时刻i的最小等待时间 #include <string.h> // f[i]=min{f[j]+i(cnt[i]-cnt[j])-(sum[i]-sum[j])} #include 阅读全文
posted @ 2022-10-09 18:38 azzc 阅读(34) 评论(0) 推荐(0)
摘要:** 斜率优化** 任务安排1 P2365 O(n^2) 时间为 t 费用为 c 状态表示: f[i] 表示 将前i个任务分为若干批执行的费用+之后的启动时间 的最小值 重要思想: 1. 费用提前计算: 处理 s 对后面的任务的影响(启动的影响) 状态计算: 枚举最后一批 i i n f[i] = 阅读全文
posted @ 2022-10-09 18:21 azzc 阅读(70) 评论(0) 推荐(0)