题目链接: D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs…
题目链接:http://codeforces.com/problemset/problem/402/C /**算法分析: 乱搞题,不明白题目想考什么 */ #include<bits/stdc++.h> #define MAXN 1050 #define PI acos(-1.0) #define REP(i,n) for(int i=0; i<n; i++) #define FOR(i,s,t) for(int i=s; i<=t; i++) #define mem(a,b) m…
题目链接: Codeforces 669D Little Artem and Dance 题目描述: 给一个从1到n的连续序列,有两种操作: 1:序列整体向后移动x个位置, 2:序列中相邻的奇偶位置互换. 问:q次操作后,输出改变后的序列? 解题思路: 刚开始只看了第一组样例,发现相邻的奇偶位一直在一起,于是乎就开始writing code,写完后发现并不是正解!!!!就去推了一下第三个样例,总是这组实例通过,那组实例卡死,,,,,,,最后终于成功的Mengbility.今天突然想起来,其实整体…
题意:给你一颗树,问这颗树是否存在一个根,使得对于任意两点,如果它们到根的距离相同,那么它们的度必须相等. 思路1:树的重心乱搞 根据样例发现,树的重心可能是答案,所以我们可以先判断一下树的重心可不可以.如果不行,剩下的只可能是度为1点当根了.当然,我们不能枚举所有度为1的点,不然一个菊花图就超时了,我的做法是对于以重心为根的树搜索一遍,对于每个深度的度数为1的点只记录一个,然后枚举这些点,如果有就是有,否则没有.这样最坏的复杂度应该能到O(n * sqrt(n)),但是肯定跑不满.至于为什么这…
题目链接: C. Bear and Up-Down time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two…
题目链接: B. Rebus time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' an…
Codeforces 题目传送门 & 洛谷题目传送门 简单题,难度 *2500 的 D2F,就当调节一下一模炸裂了的自闭的心情,稍微写写吧. 首先我看到这题的第一反应是分类讨论+数据结构,即枚举其中一个被交换的位置然后用树状数组或类似的数据结构维护另一个决策的贡献,细节似乎挺多的,大概硬刚个大分类讨论上去也可以?不过显然此题有更简便的方法所以这种方法就没写了. 我们来观察一下这个"交换"有什么性质,这个绝对值有点烦,我们不妨将所有 \(i\) 分为两类:\(a_i<b_i…
C. Page Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output «Bersoft» company is working on a new version of its most popular text editor - Bord 2010. Bord, like many other text editor…
Codeforces 题面传送门 & 洛谷题面传送门 分类讨论神题. 首先看到最大值最小,一眼二分答案,于是问题转化为判定性问题,即是否 \(\exists x_0,y_0,z_0\) 满足 \(\forall i,|x_0-x_i|+|y_0-y_i|+|z_0-z_i|\le mid\). 柿子中带个绝对值,不好直接转化.不过注意到对于任意实数 \(x\) 都有 \(x\le |x|,-x\le |x|\),因此 \(|x-y|\le v\) 的充要条件即是 \(x-y\le v,y-x\l…
题意:a是严格递增数列,bi是ai每一位的和,告诉你b1~bn,问你怎样搞才能让an最小 思路:让ai刚好大于ai-1弄出来的an最小.所以直接模拟贪心,如果当前位和前一个数的当前位一样并且后面还能生成比前一个数大的数,那么就和前一个数保持一致,否则当前位 = 前一个数当前位+ 1,后面的位数按照最小方式排列.如果排到最后每一位都和前面一个数一致,就把剩余的b从最小的一位一直加满9. 代码: #include<set> #include<map> #include<stack…