Crazy Rows】的更多相关文章

Problem You are given an N x N matrix with 0 and 1 values. You can swap any two adjacent rows of the matrix. Your goal is to have all the 1 values in the matrix below or on the main diagonal. That is, for each X where 1 ≤ X ≤ N, there must be no 1 va…
Problem You are given an N x N matrix with 0 and 1 values. You can swap any two adjacent rows of the matrix. Your goal is to have all the 1 values in the matrix below or on the main diagonal. That is, for each X where 1 ≤ X ≤ N, there must be no 1 va…
题意: 给定一个N*N的矩阵,由0,1组成,只允许交换相邻的两行,把矩阵转化为下三角矩阵(对角线上方全是0),最少需要多少次交换?(保证可以转化为下三角矩阵) Large: N<=40 解析: 假如每一行的1的个数都是不相同的,即,最终答案中的矩阵是唯一的,这就相当于求对给定数组冒泡排序需要几次交换一样.但显然,题目没有如此保证. 方法是贪心法:(策略不给出证明) 从第一行到最后一行依次满足,因为可以满足前面行的也一定可以满足后面的,所以每次只需要找到可以满足当前行的最近的就可以了. 预处理最后…
https://code.google.com/codejam/contest/204113/dashboard 题目大意: 给你一个矩阵,让你转化为下三角矩阵,每次只能交换相邻的行,求最小的交换次数. 思路: 一开始觉得记录每一行最后一个1的位置,然后相邻交换排序可以直接冒泡法(甚至可以nlogn的合并排序),结果交上去错的. 想了想因为每一行最后一个1已经满足j<=i了,所以..(设行i列j) 那么就只好贪心啦,每次选最近的要交换的. #include<cstdio> #includ…
GCJ 271 [题目大意] Minimum Scalar Product 有两个东西(滑稽)v1=(x1,x2,x3,……,xn)和v2=(y1,y2,……yn),允许任意交换v1和v2中各数字的顺序. 请计算x1y1+……+xnyn的最小值 [输入样例(第一行为n,第二行为v1,第三行为v2)] 3 1 3 -5 -2 4 1 [输出样例(直接输出最小值)] -25 [数据范围] 稍微大一点的:100<=n<=800     -100000<=x1,y1<=100000 [解题…
POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 Ball POJ 3009 Curling 2.0 AOJ 0558 Cheese POJ 3669 Meteor Shower AOJ 0121 Seven Puzzle POJ 2718 Smallest Difference POJ 3187 Backward Digit Sums POJ 3…
C - Crazy Calendar Time Limit:4000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1393 Description 2011 was a crazy year. Many people all over the world proposed on 11-11-11, married on 11-11-11, some even w…
2011 was a crazy year. Many people all over the world proposed on 11-11-11, married on 11-11-11, some even went through surgery only to have 11-11-11 as their child's birth date. How crazy people can be! Don't they see there is a "20" hidden? Th…
一直很想谈谈Continuous Integration(CI),持续集成. 就在不久前一次朋友聚会上,一个刚刚跳槽到一家创业公司的朋友跟我抱怨说他们没有CI,没有code review,要做点事太累了.而其实让这个刚刚开始上手的新手项目经理无语到吐的原因是,他们的一名主要开发人员责任心不够,很难沟通,bug率很高,还不愿加班改bug. “现在招人很难的啊,所以也不能把他fire掉,哎...” “有了CI又能怎样呢?” “至少不用等到QA发现问题,下班前就能抓住他了!不过现在我们QA连自动化测试…
Here's to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They're not fond of rules And they have no respect for the status quo. You can praise them, quote them, dis…