Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends in several days. Currently, there are totally n people in the country,…
Description We are given a figure consisting of only horizontal and vertical line segments. Our goal is to count the number of all different rectangles formed by these segments. As an example, the number of rectangles in the Figures 1 and 2 are 5 and…
题目链接:https://cn.vjudge.net/contest/280949#problem/F 题目大意:给你n个人,然后给你m个关系,每个关系输入t1, t2 .代表t1和t2是朋友关系(双向关系).然后输入一个k,代表两个人是亲密的朋友关系的话,就至少有k个共同的朋友,然后问你题目中这样的朋友有多少对? 具体思路:注意一个地方,朋友关系具有传递性,打个比方 t1和t2 变成了亲密的朋友,然后t0 本来和t1是朋友关系,但是和t2不是朋友关系,t1和t2成为朋友之后,t0也就和t2称为…
题目传送门 /* 暴力:纯暴力,在家水水 */ #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; ]; ]; i…
Description "Hike on a Graph" is a game that is played on a board on which an undirected graph is drawn. The graph is complete and has all loops, i.e. for any two locations there is exactly one arrow between them. The arrows are coloured. There…
题意:给你一个面,然后涂颜色,问你最后剩多少颜色,每种颜色面积. 思路:第一反应是二维线段树,代码又臭又长,可以做.但是这题暴力+离散化就可以过.可以看到他给的n只有100,也就是说最坏情况下会涂100次,每次最多涂200*200个点,那么完全可以用暴力.有一个地方纠结了半天,原题每一格代表了面积,我们离散化后每一格代表的是坐标点,所以我在涂面积时在起始位置+1后的位置开始涂,在算面积时,坐标左边就是涂的面积. 代码: #include<set> #include<map> #in…
Problem Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends in several days. Currently, there are totally n people in the…
Very often, especially in programming contests, we treat a sequence of non-whitespace characters as a string. But sometimes, a string may contain whitespace characters or even be empty. We can have such strings quoted and escaped to handle these case…
The vast power system is the most complicated man-made system and the greatest engineering innovation in the 20th century. The following diagram shows a typical 14 bus power system. In real world, the power system may contains hundreds of buses and t…
Description There are two rows of positive integer numbers. We can draw one line segment between any two equal numbers, with values r, if one of them is located in the first row and the other one is located in the second row. We call this line segmen…