TopCoder[SRM513 DIV 1]:PerfectMemory(500)】的更多相关文章

Problem Statement      You might have played the game called Memoria. In this game, there is a board consisting of N rows containing M cells each. Each of the cells has a symbol on its back. Each symbol occurs on exactly two cells on the board. A mov…
Problem Statement      Manao is playing a new game called Reflections. The goal of the game is transferring an artifact in 3-dimensional space from point (0, 0, 0) to point (X, Y, Z). There are two types of moves in the game: 1) The player can move t…
#include <set> #include <iostream> #include <string> #include <vector> using namespace std; class Egalitarianism { public: void DFS(vector<string> &v,int p,char flag[]) { int i,j; ;i<v.size();i++) { if (v[p][i]=='Y') {…
做了一道题,对了,但是还是掉分了. 第二道题也做了,但是没有交上,不知道对错. 后来交上以后发现少判断了一个条件,改过之后就对了. 第一道题爆搜的,有点麻烦了,其实几行代码就行. 250贴代码: #include <iostream> #include <cstring> #include <queue> #include <cmath> #include <cstdio> #include <algorithm> #include…
250: 题目大意: 在一个N行无限大的网格图里,每经过一个格子都要付出一定的代价.同一行的每个格子代价相同. 给出起点和终点,求从起点到终点的付出的最少代价. 思路: 最优方案肯定是从起点沿竖直方向走到某一行,然后沿水平方向走到终点那一列,然后再沿竖直方向走到终点那一行. 枚举是通过哪一行的格子从起点那列走到终点那列的,求个最小值就好了. 代码: // BEGIN CUT HERE // END CUT HERE #line 5 "LongMansionDiv1.cpp" #incl…
#include <string> #include <iostream> using namespace std; class SwappingDigits { public: bool notBiggest(string &s,int pos) { int len=s.length(); ; ;i<len;i++) { )) { return true; } } return false; } int findSmallest(string&s,int p…
A:应该是道语文题,注意边界就好: B:开始考虑的太复杂,没能够完全提取题目的思维. 但还是A了!我愚蠢的做法:二分答案加暴力枚举, 枚举的时候是完全模拟的,比如每次取得时候都是从大到小的去取,最后统计答案! 好吧!忽略这种SB做法,只是提供一种当你想不到的时候,一种暴力破解的思路! 看到的一种正解:我们每次可以取(N-1)个,而且不用加入答案中, 先上代码: for (int i=0;i<s.size();i++) sum+=s[i]; return max(0,sum-N*(m-1));很简…
A,B:很水,注意边界,话说HACK都是这些原因. C: R[I][J]:表示反转I-J能改变冒泡排序的次数: DP方程:dp[i][k]=max(dp[j][k],dp[j][k-1]+dp[j][i])  (0<=j<i) 最后枚举,具体看代码 #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<cmath> #inc…
1. KingdomAndTrees 给出n个数a[1..n],求一个数组b[1..n]满足b严格递增,且b[1]>=1. 定义代价为W = max{abs(a[i]-b[i])},求代价最小值. n<=50 [题解] 二分代价W,贪心判断.当前肯定越小越优,如果下一个加上当前二分的值,小于等于当前这个,那么就肯定不行,依次判即可. // BEGIN CUT HERE // END CUT HERE #line 5 "KingdomAndTrees.cpp" # inclu…
题意  给定一个长度不超过$5*10^{6}$的数列和不超过$100$个询问,每次询问这个数列第$k$小的数,返回所有询问的和 内存限制很小,小到不能存下这个数列.(数列以种子的形式给出) 时限$10s$,内存限制$13MB$ 我自己YY的分治缩小答案上下界范围第三个样例要跑$90s$左右,果断放弃 根据题目给出的条件我们知道每一个数的范围都在$[0, 10^{9}+6]$里. 那么我们开一个大小为$32000$的数组,把$[0, 10^{9}+6]$分成$32000$个大小相同的块. 然后先遍…