There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to e...
分类:
其他好文 时间:
2014-06-16 11:17:45
阅读次数:
162
上次的湘潭赛的C题,用线段树敲了下还是WA,不知道为何,我已经注意了处理相同数据,然后他们当时用的RMQ。所以学了下RMQ,感觉算法思想是一样的,RMQ用了DP或者是递推,由单个数到2^k往上推,虽然有部分重叠的,也没关系,因为RMQ是求区间最值嘛然后这道题目,要把出现次数化为最值,构造一个新的数组...
分类:
其他好文 时间:
2014-06-16 06:21:13
阅读次数:
248
K -QuadtreesTime Limit:3000MSMemory Limit:0KB64bit
IO Format:%lld & %lluSubmitStatusAppoint description:DescriptionQuadtreesA
quadtree is a represent....
分类:
其他好文 时间:
2014-06-12 23:57:11
阅读次数:
509
非常巧妙的题目,巧用cmp,注意cmp的重载
#include
#include
using namespace std;
string a[55];
bool cmp(string a, string b){
return a+b > b+a;
}
int main(int argc, char const *argv[])
{
int n;
while(cin >...
分类:
其他好文 时间:
2014-06-11 06:10:28
阅读次数:
293
Description
Problem A
The Most Distant State
Input: standard input
Output: standard output
The 8-puzzle is a square tray in which eight square tiles are placed. The remaining ninth square ...
分类:
其他好文 时间:
2014-06-10 07:59:06
阅读次数:
335
Two players, S and T, are playing a game where they make alternate moves. S plays
first.
In this game, they start with an integer N. In each move, a player removes one digit from the integer and p...
分类:
其他好文 时间:
2014-06-10 06:31:29
阅读次数:
302
题目:国际象棋,判断当前状态,哪一方被将军了。不会有同时被将军的情况。
分析:模拟。直接按照国际象棋的规则模拟即可。
把操作分成两种,单点判断和射线判断,写成函数减少公共代码,也降低错误率;
然后:兵、马、王(不用判断)都是单点判断,后、车、象都是射线判断。
每种情况,调用不同的方向向量即可。
说明:没有同时成立的情...
分类:
其他好文 时间:
2014-06-08 17:14:06
阅读次数:
265
这个题之前做过,方法太笨还不对,今天再做突然想到一个巧妙做法,网上应该也有别人用此方法的,因为并不是很难,但我没有看别人的,是自己想出来的哈哈哈
首先要对输入的数组进行排序,这是毋庸置疑的。
因为要计算绝对值的和,所以就想到了数轴上的距离的概念。要使|X1-A|+|X2-A|最小,也就是要找一个点A,使其到X1,X2距离和最短,所以很容易想到在数轴上只要A在X1和X2之间就行。...
分类:
其他好文 时间:
2014-06-08 15:20:36
阅读次数:
202
Rotating Sentences
In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to b...
分类:
其他好文 时间:
2014-06-08 04:51:34
阅读次数:
236