NCPC 2012 Bread Sorting】的更多相关文章

逆序对数的应用: 逆序对数的写法有,二分,树状数组,分治: 学习一下: 树状数组版: 代码: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int a[maxn],b[maxn],c[maxn]; int n; struct point { int num,index; bool operator<(const point& t)const { r…
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26579 考虑两个性质:蚂蚁的相对位置不变,蚂蚁碰撞时相当于对穿而过,然后排两次序就可以了.. //STATUS:C++_AC_204MS_3048KB #include <functional> #include <algorithm> #include <iostream> //#include <ext/rope> #include <fs…
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29364 题意:给一个序列,输出序列中,二进制1的个数最少的数.. 随便搞搞就行了,关于更多算法,可以看<My github>. //STATUS:C++_AC_290MS_1324KB #include <functional> #include <algorithm> #include <iostream> //#include <ext/r…
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29357 直接模拟就可以了.. //STATUS:C++_AC_190MS_1884KB #include <functional> #include <algorithm> #include <iostream> //#include <ext/rope> #include <fstream> #include <sstream&g…
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=26474 题意:给一个数列,可以对三个数操作:把最后一个数放到第一个,前两个数后移一位.问最后能否到达相应的目标序列.. 先考虑三个数A B C,变换后两种情况B C A和C A B,可以证得(列举3个数的大小情况,枚举证),这三个序列变换后的逆序对个数的奇偶性是相同的,而且只有这3个序列相同,所以A B C只能到达与之奇偶相同的序列,而且是全部能到达.那么多个数的情况也是一样的,就是多个…
题目要求每次输出中间的那个数,如果数据很大肯定扛不住: 所以用两个优先队列来维护: 这样的话中间的那个数反正会在两个队列的任何一个的头部: 时间复杂度肯定比较小: 代码: #include <cstdio> #include <queue> using namespace std; int l1,l2; priority_queue<int> q1; priority_queue<int, vector<int>, greater<int>…
湖南大学的oj上有这套比赛: 这题是个简单的计算几何,首先去掉重复的边,然后判断是否全部平行: 代码: #include<cstdio> #define maxn 105 using namespace std; struct node { int x1,y1; int x2,y2; } no[maxn]; bool cross(node a,node b) { int x=(b.x1-a.x1)*(a.y2-a.y1)-(b.y1-a.y1)*(a.x2-a.x1); int y=(b.x2…
/*给出n个原始顺序的数,再给出要排成目标状态顺序,每次从第一个数列中选择三个,把这三个数中最右边的数放在最左边,然后其他两个数右 移一个单位,为你从原始状态能不能排序成目标状态. 本人YY的结论,从特殊到一般,虽然一般的只是手证了数值比较小的:结论应该就是1到n的n个数的全排列,分成相等的奇排序和偶排序,且个数一样,同个集合中的排列可以互相转换 比如1 2 3 4的全排1 2 3 4 1 4 2 3 1 3 4 2 4 1 3 2 4 2 1 3 4 3 2 1 2 4 3 1 2 1 4 3…
[原文发表地址]  Beginning LightSwitch in VS 2012 Part 4: Too much information! Sorting and Filtering Data with Queries [原文发表时间]  2012-08-15 18:03 说明:本文是将之前所编的Visual Studio LightSwitch 2011 博文更新到Visual Studio 2012 中的LightSwitch, 若要查看原文版本,请点击这里. 欢迎来到开始Visual…
WebGrid with filtering, paging and sorting by Jose M. Aguilar on April 24, 2012 in Web Development A few days ago I received some questions on the use of the Webgrid helper in the comments section of my personal blog, specifically on how to implement…