题意 题目链接 Sol 显然如果题目什么都不说的话需要\(\frac{n * (n - 1)}{2}\)个相对关系 然后求一下传递闭包减掉就行了 #include<bits/stdc++.h> using namespace std; const int MAXN = 1001; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f =…
题应该是假的...先不做了 https://www.cnblogs.com/Blue233333/p/7249057.html 比如输入5 0,答案是10,但可以比较8次就出来.就是在一个已知有序数列中二分插入一个数 例如5 0: 记f(x)=ceil(log2(x)),则此时答案为f(1)+f(2)+f(3)+f(4)+f(5)=8,而不是10 但是在已经提供一些信息的情况下就更搞不清楚了....…
*传送 FJ想按照奶牛产奶的能力给她们排序.现在已知有N头奶牛(1 ≤ N ≤ 1,000).FJ通过比较,已经知道了M(1 ≤ M ≤ 10,000)对相对关系.每一对关系表示为“X Y”,意指X的产奶能力强于Y.现在FJ想要知道,他至少还要调查多少对关系才能完成整个排序. 这道题和Floyd--P2419 [USACO08JAN]牛大赛Cow Contest有异曲同工之妙啊,但是2419我用的是floyd,对于n^3的做法,本题的数据范围n<=1000显然只能得到部分分(并不会bitset优…
HAOI2006 (洛谷P2341)受欢迎的牛 题解 题目描述 友情链接原题 每头奶牛都梦想成为牛棚里的明星.被所有奶牛喜欢的奶牛就是一头明星奶牛.所有奶 牛都是自恋狂,每头奶牛总是喜欢自己的.奶牛之间的"喜欢"是可以传递的--如果A喜 欢B,B喜欢C,那么A也喜欢C.牛栏里共有N 头奶牛,给定一些奶牛之间的爱慕关系,请你 算出有多少头奶牛可以当明星. 输入输出格式 输入格式: 第一行:两个用空格分开的整数:N和M 第二行到第M + 1行:每行两个用空格分开的整数:A和B,表示A喜欢B…
传送门啦 这是一个tarjan强连通分量与出度结合的例题. 先明确一下题意,如果这个点(缩点之后的)没有出度,这个点才能成为明星牛(明星牛的定义是:所有牛都喜欢他才可以). 由于我们进行了缩点,所以我就另外开一个数组num[i]:表示这个强连通分量中有多少个点. int sum = 0; for(int i=1;i<=cnt;i++) if(!chu[i]) ans = num[i] , sum++; if(sum >= 2) printf("0"); else print…
P2990 [USACO10OPEN]牛跳房子Cow Hopscotch 题目描述 The cows have reverted to their childhood and are playing a game similar to human hopscotch. Their hopscotch game features a line of N (3 <= N <= 250,000) squares conveniently labeled 1..N that are chalked o…
题目大意:三种操作: $+Name\;Socore:$上传最新得分记录,把以前的记录删除. $?Name:$ 查询玩家排名.如果两个玩家的得分相同,则先得到该得分的玩家排在前面. $?Index:$ 返回自第$Index$名开始的最多$10$名玩家名字. 题解:平衡树,支持删除,插入,查询第$k$名,查询一个玩家的排名. 卡点:新建节点时忘记赋$size$ C++ Code: #include <cstdio> #include <map> #include <iostrea…
P1360 [USACO07MAR]黄金阵容均衡Gold Balanced L… 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For ex…
P3047 [USACO12FEB]附近的牛Nearby Cows 题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into account, he wants to plant enough grass in each of his fields not only for the cows situated initially in that field, but…
P1360 [USACO07MAR]黄金阵容均衡Gold Balanced L… 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For ex…