传送门 首先考虑如何算出答案,考虑枚举中间那个点,显然每个点作为中间的点的次数为入度乘出度 所以答案就是每个点的入度乘出度之和 然后每个点开一个 $vector$ 维护从它出去的点数,每次修改的时候直接暴力改出度然后暴力删边并加入新边 这样可以证明复杂度是对的,这里有两种证明,其中第二种是来自官方题解 证明 $1$ : 不妨让值小的点指向值更大的点 首先对于所有出度小于根号 $m$ 的点,单次暴力复杂度显然小于 $\sqrt {m}$,那么总复杂度不超过 $q \sqrt {m}$ 对于出度大于…
F. Konrad and Company Evaluation 参考:[codeforces 1230F]Konrad and Company Evaluation-暴力 思路:题意分析见参考博客.因为求的是三元组的个数,所以在保存的时候的时候就保存为有向图,让工资少的员工指向工资多的员工,那么求三元组的时候,只需要以三元组中间的那个员工为参考点来求解即可. ll cal(int i) { return (cnt[i]-g[i].size())*g[i].size(); } 那么当进行操作的时…
直接建反边暴力 复杂度分析见https://blog.csdn.net/Izumi_Hanako/article/details/101267502 #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ll out[MAXN], in[MAXN]; vector<int> G[MAXN]; int main() { int n, m; scanf("%d %d", &n…
题意:有i个人,m对两两之间的关系,第i个人初始的薪水为i,有q次操作,第i次操作会把v[i]号的薪水提升成n+i 如果两个人之间存在关系,薪水高的会向薪水低的炫耀 定义u,v,w为一个三元组,当u向v炫耀,v向w炫耀 要求每次操作后输出当前三元组个数 n,m,q<=1e5 思路:将人看成点,关系看成边,定义方向为从小到大 显然每次操作后被操作的人的薪水都会变成最大的,等价于将它的所有出边变成入边 答案即为所有点的入度*出度之和 vector暴力维护出边 学习了一下杜教的写法 势能分析见http…
题目链接: D. Restructuring Company time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Even the most successful company can go through a crisis period when you have to make a hard decision — to re…
[题目链接]:http://codeforces.com/contest/794/problem/C [题意] 有n个位置; 两个人; 每个人都有n个字符组成的集合s1,s2(可以有重复元素); 然后两人轮流从各自的集合中取出一个字符; 把它放在这n个位置中的任意一个位置; 其中一个人想要让这n个字符组成的字符串字典序尽量小; 另外一个人则想让他尽量大; 问你最后字符串会变成什么样 [题解] s1和s2是两个人的集合 可以先把s1升序排; 然后s2降序排; 设ls1,ls2分别为s1和s2最左的…
题目链接:http://codeforces.com/contest/794/problem/C 题意:有两个人每个人都有一个长度为n的字符串,两人轮流拿出一个字符串,放在一个长度为n的字符串的指定位置中,第一个 人他想让最后组成的字符串尽可能小,另一个人想要字符串尽可能的大.他们互相知道各自手中有什么字符串,最后输出组成的 字符串 #include <iostream> #include <cstring> #include <string> #include <…
Description 一开始有 \(n\) 个元素,可以进行几个操作. 合并 \(x,y\) . 合并 \(x,x+1,...,y\) . 询问 \(x,y\) 是否在一个集合中. Sol 并查集+链表. 第二个询问,一直用链表找 \(pre\) 优化一下就可以了. 另外 51Nod 1525 重组公司. Code #include<cstdio> #include<utility> #include<algorithm> #include<iostream&g…
1. 1229A Marcin and Training Camp 大意: 给定$n$个对$(a_i,b_i)$, 要求选出一个集合, 使得不存在一个元素好于集合中其他所有元素. 若$a_i$的二进制中某一位为$1$, $a_j$对应位为$0$, 那么$(a_i,b_i)$好于$(a_j,b_j)$. 显然出现次数不少于$2$的数都可以选, 然后再把包含关系的数全选了即可. #include <iostream> #include <sstream> #include <al…
传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() //#define Local using namespace std; typedef long long ll; typedef pair<int, int> pii; con…
FROM:http://www.cnblogs.com/crabo/p/CRACK_MATRIX_XMPP.html 如此著名的XMPP , 居然试过jabber-net, agsXmpp,matrix Xmpp, 无数多个例子, 居然没有一个能实现最简单的 发消息.收消息功能.好无语. 最后还是决定从商业产品 Matrix Xmapp 入手, 最终得以成功.因为是个人简单测试, 但又不喜欢30天的license, 爆破一下. 1. 下载发现有.NET 版,MONO版,SilverLight版,…
如此著名的XMPP , 居然试过jabber-net, agsXmpp,matrix Xmpp, 无数多个例子, 居然没有一个能实现最简单的 发消息.收消息功能.好无语. 最后还是决定从商业产品 Matrix Xmapp 入手, 最终得以成功.因为是个人简单测试, 但又不喜欢30天的license, 爆破一下. 1. 下载发现有.NET 版,MONO版,SilverLight版, .NET版文件最大, 同时也发现使用PublicToken. 关键资源串外置到Resource,大致就是说, .NE…
Poster CodeForces - 412A The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to…
1.Zookeeper安装及启动 可参考这篇文章https://www.cnblogs.com/geekdc/p/5948326.html 从下载到启动都描述的很详细,按照文章一步一步走即可. 2.Dubbo-admin搭建及启动 dubbo-admin的配置及启动推荐一篇文章https://blog.csdn.net/qq_28988969/article/details/79866111 Github(https://github.com/apache/incubator-dubbo/tre…
传送门 D. Restructuring Company time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Even the most successful company can go through a crisis period when you have to make a hard decision — to rest…
B. Kefa and Company Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/problem/B Description Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company. Kefa has n friends, each friend wi…
http://codeforces.com/contest/794/problem/C Description Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the…
题目链接:https://codeforces.com/contest/1090/problem/A A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to s…
E. MST Company time limit per test 8 seconds memory limit per test 256 megabytes input standard input output standard output The MST (Meaningless State Team) company won another tender for an important state reform in Berland. There are n cities in B…
E - Company 思路: 首先,求出每个点的dfs序 然后求一些点的公共lca, 就是求lca(u, v), 其中u是dfs序最大的点, v是dfs序最小的大点 证明: 假设o是这些点的公共lca, in[o]是o的入时间戳, out[o]是o的出时间戳, 那么对于任意一点x, in[o] <= in[v] <= in[x] <= in[u] <= out[o] 所以o是x的祖先 所以o是这些点的公共lca 所以只要求出每段区间的dfs序最大的和最小的, 删除的要么是最大的,…
https://codeforces.com/contest/1062/problem/E 题意 给一颗树n,然后q个询问,询问编号l~r的点,假设可以删除一个点,使得他们的最近公共祖先深度最大.每次询问,输出删除的点和祖先的深度 思路 考虑dfs序来判断v是否在u的子树里: dfn[u]<dfn[v]<=max(dfn[u的子树]) 那么进一步拓展,dfs序之差越大,点就在越分离的地方,这些点的lca一定是lca(max(dfn[u]),min(dfn[u])) 这不仅知道了需要去掉哪个点(…
Description The company \(X\) has \(n\) employees numbered from \(1\) through \(n\). Each employee \(u\) has a direct boss \(p_u\) \((1 \le p_u \le n)\), except for the employee \(1\) who has no boss. It is guaranteed, that values \(p_i\) form a tree…
http://codeforces.com/problemset/problem/580/B 题意:Kefa有n个朋友,要和这n个朋友中的一些出去,这些朋友有一些钱,并且和Kefa有一定的友谊值,要求这些朋友间的贫富差距(拥有的钱的数量)小于d,要求Kefa邀请出来的朋友的友谊值和最大,并输出这个最大值. #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm&g…
[题目]C. Bear and Company [题意]给定大写字母字符串,交换相邻字符代价为1,求最小代价使得字符串不含"VK"子串.n<=75. [算法]动态规划 [题解]关键在于表示状态,我们将确定下来的前若干个固定作为状态,后面新加的字符不会进入固定的前若干个.(为了方便,非'V''K'的字符皆为‘X') 由于相同字符显然不可能跨越,那么前若干个的有效信息只有:它是由前v个’V',前k个‘K',前x个’X'组成的,最后一个字符是否’V',即f[v][k][x][0/1].…
http://codeforces.com/contest/794/problem/C 题意: 有两个人要为公司起名字,每个人手中都有n个字符,现在要取一个n个字符长度的公司名.两人轮流取名,每次选择一个字符,可以任意选择放在1~n还未放置字符的位置上,每个字符限用一次. 现在第一个人希望公司名字典序越小越好,而第二个人希望字典序越大越好.输出最后的公司名. 思路: 首先肯定是要排序的,第一个人肯定去用前面最小的几个,而第二个人肯定去用前面最大的几个. 轮到第一个人时,我们首先将他手中最小的字符…
题意与分析(CodeForces 580B) \(n\)个人,告诉你\(n\)个人的工资,每个人还有一个权值.现在从这n个人中选出m个人,使得他们的权值之和最大,但是对于选中的人而言,其他被选中的人的工资不能超过他的工资+d. 这题用尺取法可以漂亮的解决.尺取法按照<挑战>一书的定义,是"指对数组保存一对下标(起点和终点),然后根据实际情况交替推进两个端点直到得到答案"的一种方法,因为这种操作"很像是尺蠖(日文中称为尺取虫)爬行的方式"而得名. 具体到这…
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company. To settle this problem, they've decided to play…
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company. To settle this problem, they've decided to play…
原题链接:http://codeforces.com/contest/580/problem/B 题意: 给你一个集合,集合中的每个元素有两个属性,$m_i,s_i$,让你求个子集合,使得集合中的最大m的差不超过d的情况下,s的和的最大值. 题解: 先排序,然后对于a[i],直接二分a[i].s+d的位置,然后维护一个前缀和,更新答案即可. 代码: #include<iostream> #include<cstring> #include<algorithm> #inc…
Restructuring Company Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and merge departments, fire employees and do other unpleasant stuff. Let's consider the following mo…