Codeforces Codeforces Round #484 (Div. 2) D. Shark 题目连接: http://codeforces.com/contest/982/problem/D Description For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and…
题意:给你一个序列,让你找一个k,倘若把大于等于k的元素都标记为不可用,那么剩下的所有元素形成的段的长度相同,并且使得段的数量尽量大.如果有多解,输出k尽量小的. 把元素从大到小排序插回原位置,用一个set维护前驱后继,相当于删除一个原有的段,然后将这个段切成两半,产生两个新的段.维护这次操作后所有段的长度以及各种长度的出现次数(用multiset),一旦合法,就尝试更新答案. #include<cstdio> #include<algorithm> #include<set…
Codeforces Codeforces Round #484 (Div. 2) E. Billiard 题目连接: http://codeforces.com/contest/982/problem/E Description Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at t…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把序列生成的过程看成一颗树 会发现最后形成的是一颗二叉树. 每个二叉树上的节点就对应了序列中的一个数字. 如果我们把每个节点都往下投影的话. (而且整棵树都是左右对称的.那么每个子树的根节点就是(l+r)/2了 就像是整个序列了. (中序遍历 则我们可以用线段树求区间和的方法. 现在相当于告诉你1..n这个区间. 然后你要求l..r这个区间的和. 递归求就好. [代码] #include <bits/stdc++.h> #de…
题意:给你一个台球桌面,一个台球的初始位置和初始速度方向(只可能平行坐标轴或者与坐标轴成45度角),问你能否滚进桌子四个角落的洞里,如果能,滚进的是哪个洞. 如果速度方向平行坐标轴,只需分类讨论,看它是否在台球桌的边沿即可. 如果速度方向和坐标轴成45度,如下图 将整个过程展开, 设出射方向与当前所在桌面的两个边沿的距离分别为X,Y,则有方程X+pn=Y+qm,扩欧可求得解.然后再根据p.q的奇偶性即可确定滚进的是哪个洞(根据图中洞编号的翻折关系).…
题意:给你一棵树,让你切掉尽可能多的边,使得产生的所有连通块都有偶数个结点. 对于一棵子树,如果它有奇数个结点,你再从里面怎么抠掉偶数结点的连通块,它都不会变得合法.如果它本来就有偶数个结点,那么你怎么抠,都是合法的. 所以,我们只需要切断所有有偶数结点的子树的父边即可. 然后再判一遍最后是否仍是合法的. #include<cstdio> #include<cstring> using namespace std; int n; int e,first[100005],nex[20…
题目链接:http://codeforces.com/contest/982 A. Row time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output You're given a row with nn chairs. We call a seating of people "maximal" if the two follow…
原博主:https://blog.csdn.net/amovement/article/details/80358962 B. Bus of Characters time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In the Bus of Characters there are nn rows of seat, each h…
题目链接 题意:给你一棵树,让你尽可能删除多的边使得剩余所有的联通组件都是偶数大小. 思路:考虑dfs,从1出发,若当前节点的子节点和自己的数目是偶数,说明当前节点和父亲节点的边是可以删除的,答案+1,因为最开始的节点没有父节点,所以最后答案-1 #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mp make_pair #define pb push_back usi…
Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main(){ , s, d; scanf("%d", &n); while(n--) { scanf("%d%d", &a…