Kattis - Different Distances】的更多相关文章

Input The input file contains up to 10001000 test cases, each of which contains five real numbers, x1 y1 x2 y2 px1 y1 x2 y2 p, each of which have at most 1010 digits past the decimal point. All are in the range (0,100](0,100]. The last test case is f…
Biased Standings Usually, results of competitions are based on the scores of participants. However, we are planning a change for the next year of IPSC. During the registration each team will be able to enter a single positive integer – their preferre…
Distances to Zero 题目链接:http://codeforces.com/problemset/problem/803/B 题目大意: 给一串数字,求每个数字到离他最近数字0的距离...水题 例:2 1 0 3 0 0 3 2 4 输出:2 1 0 1 0 0 1 2 3 思路: 每次读入一个数字要么是0要么不是0 ①如不是0 到0最近距离等于左边那位距离+1 ②如是0 本身距离为0 向左循环,如果到现在输入0距离 小于 到上一个0的距离 就更新距离,到不小于位置即可 AC代码:…
An undirected, connected tree with N nodes labelled 0...N-1 and N-1 edges are given. The ith edge connects nodes edges[i][0]and edges[i][1] together. Return a list ans, where ans[i] is the sum of the distances between node i and all other nodes. Exam…
题目:Bear and Clique Distances 描述:共有N个点,前1—K个点任意两点之间有一条无向边,边的权值为X,再任意给M条边(u,v,w)(不重复),求任意一点到其余各点的最短路. 分析: 1.最短路算法(usual Dijkstra)+一点小变形(a little twist) 2.trick:设置一个变量upd=1;因为前K个点之前两两是连通的,所以当第一次到前K个点中任一点(假设为u)时,就可以更新得到前K个点的距离(除了u)d[i](i<=k)为d[u]+X. 即:1-…
题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: #include<bits/stdc++.h> using namespace std; # define ll long long # define inf 0x3f3f3f3f ; ll cal(ll a, ll b,ll c,ll n){ ); )return (b/c); ll tmp=…
题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面积的期望. 具体思路:我们肯定不能硬跑每一个k边形,肯定会超时.我们以每个点作为起点,从这个点开始,形成的面积的期望是多少,然后遍历每一个点,这样算出来的会有重复,最后除以2就可以了. 然后算面积的时候,我们分开算.一个多边形的面积等于每个点按照顺时针或者是逆时针两个点之间的叉积. 求组合数的时候,…
题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些连续子串中的非连续子串中包含t的有多少个. 具体思路:我们枚举s的每一个位置,然后判断一下s的包含t的非连续子串中到达那个位置,然后这个字符串两边的长度相乘就是当前位置开始,满足条件的字符位置.然后我们在找从上一次找到首字母位置下一个开始, 继续往下找就可以了. AC代码: #include<bit…
题目链接: G - Intersecting Rectangles Kattis - intersectingrectangles 题目大意:给你n个矩形,每一个矩形给你这个矩形的左下角的坐标和右上角的坐标,然后问你这些矩形会不会相交,如果存在相交的点,输出1,否则输出0. 具体思路:扫描线,我们首先对x进行排序,然后判断当前x直线对应的线段上是否有x已经覆盖,如果已经有就证明存在相交的情况.但是这样会存在多算的情况,所以我们对于每一个矩形的左端点打一个标记,然后右端点再打一个标记,当左端点的时…
题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x, y)最深处放一个抽水机, 问最多能抽多少水,周围8个方向的水会流过来. 具体思路:对于每一个海拔小于0的点,判断这个点周围有水的最低高度.然后将这些高度加起来就可以了. AC代码: #include<bits/stdc++.h> using namespace std; # define ll…