首页 > TAG信息列表 > mxn

CF1691F 题解

CF1691F link Rd795 题解滞销,帮帮我(误 不难想到换根 dp,然后我们可以写出如下式子: \[f_u=\left(\dbinom{\mathrm{sz}_u}{k}-\sum_{v}\dbinom{\mathrm{sz}_v}{k}\right)\mathrm{sz}_u+\sum_{v}f_v \]具体含义就是:考虑这 \(k\) 个点,什么时候 \(\operatorname{lca}\) 为 \(u\)。 减法

CF1691D 题解

CF1691D link Rd795 题解滞销,帮帮我(误 首先对于这个式子,不难注意到左边的 \(\max\) 只有 \(O(n)\) 种取值,所以想到枚举最大值是一件很自然的事。 那么可以变成枚举一个最大值 \((\mathrm{pos}, v)\),然后记 \(\mathrm{minL}\) 和 \(\mathrm{maxR}\) 为它能向左向右最长能延申到的地

CF Edu129 div2

edu129div2 A 最优策略是拿最大值。 // Problem: A. Game with Cards // From: Codeforces - Educational Codeforces Round 129 (Rated for Div. 2) // URL: https://codeforces.com/contest/1681/problem/A // Time: 2022-05-23 22:35 // Author: lingfunny #include <bits/std

CF 793 div2 E 题解

793div2 E 可上 CF 看本题解。 建模不多说,你会把排列拆成若干个轮换,然后对于长为 \(k\) 的轮换,会且仅会用 \(k-1\) 次交换(因为题目保证用的次数是最少的)。 把这些交换抓出来建图,会得到一个森林,你需要给每条边定向,使得每棵树的拓扑序都可以和原轮换循环同构。 考虑如果满足一个 \(i

ZooKeeper分布式配置——看这篇就够了

ZooKeeper 的由来 PS:这一节不重要, 不感兴趣的小伙伴可以跳过 ZooKeeper 最早起源于雅虎研究院的一个研究小组,在当时,研究人员发现,在雅虎内部有很多的大型系统基本上都需要依赖一个类似的系统来进行分布式协调,但是这些系统往往都存在分布式单点的问题,所有雅虎的开发人员就尝试开发了

hdu 3068 最长回文(马拉车)

目录 问题分析代码 问题 hdu 3068 最长回文 - https://acm.hdu.edu.cn/showproblem.php?pid=3068 分析 暴力搜索(tle)马拉车O(n) 代码 暴力搜索 #include<bits/stdc++.h> using namespace std; const int MXN = 1e5+10; char s[MXN]; int expand(int l, int r){ // 扩展

hdu 1150

题目 :Problem - 1150 (hdu.edu.cn) #include<bits/stdc++.h> using namespace std; #define MXN 110 int n,m,g[MXN][MXN],linker[MXN]; bool used[MXN]; bool dfs(int a){ for(int i=0;i<m;i++){ if(g[a][i]==1&&used[i]!=1){ used[i]=true; if(lin

bzoj4221 过不了做法

考场上连正解的第一步都没有想到,所以推出来了这个怪异的算法。 我看着这个题面,就想着把每个袋鼠表示成一个区间[bi,ai],这样当某些区间两两没有交集,就可以合并成一个大的区间。而最后没有区间能合并了,说明剩下的区间有交集。考虑枚举这个交集[l,r]。 此时我们的做法看着还是很离谱,

HDU 2084 数塔

链接 数塔 - http://acm.hdu.edu.cn/showproblem.php?pid=2084 分析 自顶而下 —— 总共有 2 n 2^n 2n条路径。因为每

HDU4165 Pills

链接 Pills - http://acm.hdu.edu.cn/showproblem.php?pid=4165 分析 共N片,每一片都会被取到,因此取到完整的一片的次数是N每一次取到完整的一片,都会有半片放回,故共有N个半片每一个半片都会被取到取到完整的一片次数一定不少于取到半片的次数结论:符合

1050

Hdu 1050 Moving Tables #include <bits/stdc++.h> using namespace std; #define MXN 210 // r[]房号对应的走廊编号,c[]计数 int n, r[MXN<<1], c[MXN]; int main(){ int T, n, s, t; scanf("%d", &T); for(int i = 1; i <= 200; i++) // 房号

bzoj4543 长链剖分

为啥我写的都是模板题题解啊 像这种题就得耐心把式子列出来,写出来也不多。为什么某题解用的普通dsu误导人啊,不用长剖写这题的都是毒瘤。 #include<bits/stdc++.h> using namespace std; #define forg(i,x) for(register int i=fir[x];i;i=nxt[i]) #define uu unsigned #define sca

SSL-OI夏日合宿 2020.08.18

SSL-OI夏日合宿 2020.08.18 今天大佬们都去打NOI网络同步赛了, 就我一个没报名QwQ. 于是就只有一个组别, 好像题还挺简单.(不是 然后就被初一爆踩了 /doge T1 分火腿 题意 给出\({n}\)根火腿, 要求切成大小相等的\({m}\)份. 求最小切几刀. 故事 显然这是一道给小学生写的水题.

HDU - 2586 How far away ?

There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A to house B"? Usually it hard to answer. But luckily int this village the ans

H - 遥远的糖果 HihoCoder - 1478

给定一个N x M的01矩阵,其中1表示人,0表示糖。对于每一个位置,求出每个位置离糖的最短距离是多少。 矩阵中每个位置与它上下左右相邻的格子距离为1。 Input 第一行包含两个整数,N和M。 以下N行每行M个0或者1。 数据保证至少有1块糖。 1 ⇐ N, M ⇐ 800 Output 输出N行,每行M个空格分隔

Codeforces 1188E Problem from Red Panda (计数)

题目链接 https://codeforces.com/contest/1188/problem/E 题解 我们可以发现,题目要求数的目标状态的个数,实际上就是在数操作序列(指每个气球操作的次数构成的序列,第 \(i\) 个颜色操作 \(b_i\) 次)的个数。可以发现如果给定了操作序列,每次一定是操作那个剩下的 \(a_i\) 最小的。那么

积分图像

由于SURF中,有用到积分图像,网上搜找了原理后,在此简要解释下。 一、积分图像:   积分图像最初应用于Harr特征提取部分,后经过发展,也可应用于均值滤波、二值化图像等对像素值进行遍历、加减的算法中。 二、积分图像的实现:    暂留个还可以的传送门https://www.cnblogs.com/magic-42

牛客练习赛58

牛能和宝石 #include <cstdio> #include <queue> #include <algorithm> #include <iostream> #include <set> #include <map> using namespace std; #include <cstdio> #define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);co

交互式

  D. Kuroni and the Celebration This is an interactive problem. After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disorie

HDU - 2018 :递推

http://acm.hdu.edu.cn/showproblem.php?pid=2018 #include <stdio.h> #include <cstring> #include <algorithm> #include <vector> #include <map> #include <assert.h> #include <set> #include <cmath> #include <qu

畅通工程 (最小生成树)(最短路径和)

Problem Description 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。     Input

P1966 火柴排队

//P1966 火柴排队#include<bits/stdc++.h>using namespace std;typedef long long ll;const int mod=99999997;const int mxn=1e6+5;int n;int /*a1[mxn],a2[mxn],d1[mxn],d2[mxn],*/c[mxn],r[mxn];struct ss{ int v,num;}a[mxn],b[mxn];bool cmp(ss a,ss b){ return

逆序对模板(树状数组)

//P1908 逆序对#include<bits/stdc++.h>using namespace std;typedef long long ll;const int mxn=5e5+5;int a[mxn],c[mxn],b[mxn],f[mxn];int n;inline int lowbit(int x){ return x&-x;}inline ll get(int x){ ll sum=0; for(;x;x-=lowbit(x)){ sum

【luogu 2529】【SHOI 2001】击鼓传花

【原题题面】传送门 【题解大意】 这篇题解写得太清晰易懂了,我就不赘述了。 讲讲在上面那篇博客中没有直接写出来但是可能影响理解的东西: f(x) = f(x/5) × a(x % 20) 已知非零的最后一位一定是偶数之后,我们考虑把每20个数分成一组,这样他们相乘4*4%10==6 对后面分不成一块的数的乘

[HNOI2018]排列

Description: 给定 \(n\) 个整数 \(a_1, a_2, \dots, a_n, 0 \le a_i \le n\),以及 \(n\) 个整数 \(w_1, w_2, \dots, w_n\)。称 \(a_1, a_2, \dots, a_n\)的 一个排列 \(a_{p[1]}, a_{p[2]}, \dots, a_{p[n]}\)为 \(a_1, a_2, \dots, a_n\)的一个合法排列,当且仅当该排列满足:对于任意