B. Polygons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is stric…
Codeforces Round #113 (Div. 2) B. Polygons 题意 给一个\(N(N \le 10^5)\)个点的凸包 \(M(M \le 2 \cdot 10^4)\)次询问,每次给一个点判断该点是否在凸包内. 思路 按\(y\)坐标将凸包分成两部分. 在左右两边二分找出夹住该点的\(y\)值区间,判断叉积正负. 代码 B. Polygons D. Shoe Store 题意 有\(N \le 10^5\)双鞋,每双鞋价格为\(c_i \le 10^9\),大小为\(s…
题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点的方案数. 思路: 打表找规律得到的序列是0,3,6,21,60,183,546,1641,4920,14763,通过肉眼看或者oeis可以得到规律为. dp计数:dp[i][j]表示在第i步时站在位置j的方案数,j的取值为[0,3],分别表示D,A,B,C点,转移方程肯定是从其他三个点转移. 代码…
Tetrahedron time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly. An ant is standing in the verte…
https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y=x^2+bx+c=>y+x^2=bx+c\),转换为点\((x,y+x^2)\)在bx+c的直线上 两个点确定一条抛物线,同时也确定了一条直线 需要选择最上面那些点相邻确定的抛物线,所以维护一个上凸包即可 维护上凸包,当前点在前进方向左边需要向后退,cross(a,b)>=0 代码 #inclu…
C. Edgy Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a tree (a connected undirected graph without cycles) of nn vertices. Each of the n−1n−1 edges of the tree is col…
C. They Are Everywhere time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from left…
B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape. The pine's trunk in…
LCA求树上两点最短距离,如果a,b之间距离小于等于k并且奇偶性与k相同显然YES:或者可以从a先走到x再走到y再走到b,并且a,x之间距离加b,y之间距离+1小于等于k并且奇偶性与k相同也输出YES:或者从a走到y再走到x再走到b,并且总距离+1小于等于k并且奇偶性与k相同同样输出YES:否则输出NO. #define HAVE_STRUCT_TIMESPEC #include <bits/stdc++.h> using namespace std; ]; int cnt; struct e…
Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出由-1和1组成的n个数,现在任意选定一个起点,从起点开始向左向右k个k个地拿走.最后问abs(cnt(-1)-cnt(1))最大是多少. 题解: 由于n和k最多只有100,所以枚举起点直接暴力就好了. 代码如下: #include <bits/stdc++.h> using namespace s…