早早地水完了三道题,pt1000用的是dfs,开始做的时候误认为复杂度最多就O(2^25),结果被一组O(2*3^16)的数据接近1e8给cha了。继续努力。

pt250:求两个串的前缀组成的不同串数目。set搞定。

 /*
*Author: Zhaofa Fang
*Created time: 2013-07-10-18.54
*Language: C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std; typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPD(i,n) for(int i=(n-1);i>=0;i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)
#define eps 1e-8 class TopFox{
public :
int possibleHandles(string f, string g){
set<string>S;
int lenf = f.length();
int leng = g.length();
REP(i,lenf){
REP(j,leng){
string tmp = "";
REP(k,i+)tmp += f[k];
REP(k,j+)tmp += g[k];
S.insert(tmp);
}
}
return S.size();
}
};

250

pt500:给定一幅图的连接情况,要求相邻两个点的差不大于d,求点之间的最大差。

    可以对每个点进行bfs,比较直观。也有一些人用的是floyd,道理一样的。

 /*
*Author: Zhaofa Fang
*Created time: 2013-07-10-18.54
*Language: C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std; typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPD(i,n) for(int i=(n-1);i>=0;i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)
#define eps 1e-8 class Egalitarianism{
public :
bool vist[];
int mon[];
bool OK;
int bfs(int s,vector <string> isFriend, int d){
int n = isFriend.size();
queue<int>Q;
Q.push(s);
int ans = -;
memset(vist,,sizeof(vist));
mon[s] = ;
vist[s] = ;
while(!Q.empty()){
int now = Q.front();
Q.pop();
REP(i,n){
if(isFriend[now][i] == 'Y' && !vist[i]){
Q.push(i);
mon[i] = mon[now] + d;
vist[i] = ;
ans = max(ans,mon[i]);
}
}
}
REP(i,n)if(!vist[i])return -;
return ans;
}
int maxDifference(vector <string> isFriend, int d){
int n = isFriend.size();
int ans = -;
REP(i,n)ans = max(bfs(i,isFriend,d),ans);
return ans;
}
};

500

pt1000:给定一组数kind[],从中取K个,取得的数为found[],能有多少种可能。其中一组sample如下:

{1, 2, 1, 1, 2, 3, 4, 3, 2, 2}
{4, 2}
3
Returns: 6
The archeologist excavated one of six possible triples of building sites:

  • (1, 4, 6)
  • (1, 6, 8)
  • (1, 6, 9)
  • (4, 6, 8)
  • (4, 6, 9)
  • (6, 8, 9)

  正解dp。很简单的转移-__-。

 /*
*Author: Zhaofa Fang
*Created time: 2013-07-10-18.54
*Language: C++
*/
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std; typedef long long ll;
#define DEBUG(x) cout<< #x << ':' << x << endl
#define FOR(i,s,t) for(int i = (s);i <= (t);i++)
#define FORD(i,s,t) for(int i = (s);i >= (t);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPD(i,n) for(int i=(n-1);i>=0;i--)
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define ft first
#define sd second
#define lowbit(x) (x&(-x))
#define INF (1<<30)
#define eps 1e-8 ll C[][]; void pre(){
C[][] = C[][] = ;
FOR(i,,){
C[i][] = ;
FOR(j,,i)C[i][j] = C[i-][j-] + C[i-][j];
}
}
class Excavations2{
public :
int ff[];
ll dp[][];
ll count(vector <int> kind, vector <int> found, int K){
pre();
int len = kind.size();
memset(ff,,sizeof(ff));
REP(i,len)ff[kind[i]]++;
memset(dp,,sizeof(dp));
int n = found.size();
FOR(i,,ff[found[]]){
dp[][i] = C[ff[found[]]][i];
}
FOR(i,,n){
FOR(j,,K){
FOR(k,,ff[found[i-]])
dp[i][j] += dp[i-][j-k]*C[ff[found[i-]]][k];
}
}
return dp[n][K];
}
}; //int main(){
// //freopen("in","r",stdin);
// //freopen("out","w",stdout);
//
// return 0;
//}

1000

SRM 584 div2的更多相关文章

  1. TC SRM 584 DIV2

    250pt: 水题set处理. 500pt: 题意: 给你一个图,每条边关联的两点为朋友,题目要求假设x的金钱为y,则他的左右的朋友当中的钱数z,取值为y - d <= z <= y + ...

  2. SRM 657 DIV2

    -------一直想打SRM,但是感觉Topcoder用起来太麻烦了.题目还是英文,不过没什么事干还是来打一打好了.但是刚注册的号只能打DIV2,反正我这么弱也只适合DIV2了.. T1: 题目大意: ...

  3. Topcoder Srm 673 Div2 1000 BearPermutations2

    \(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...

  4. Topcoder Srm 671 Div2 1000 BearDestroysDiv2

    \(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...

  5. 记第一次TopCoder, 练习SRM 583 div2 250

    今天第一次做topcoder,没有比赛,所以找的最新一期的SRM练习,做了第一道题. 题目大意是说 给一个数字字符串,任意交换两位,使数字变为最小,不能有前导0. 看到题目以后,先想到的找规律,发现要 ...

  6. TC SRM 584 DIV 2

    第一次在DIV2 AK了. 250水题. 500,FLoyd搞出所有边的最短路,然后找最短路,中最长的,如果有不连通的边返回-1 1000,组合DP,各种慌乱,在最后1分钟时,交上了,感觉很棒,最后还 ...

  7. Topcoder srm 632 div2

    脑洞太大,简单东西就是想复杂,活该一直DIV2; A:水,基本判断A[I]<=A[I-1],ANS++; B:不知道别人怎么做的,我的是100*N*N;没办法想的太多了,忘记是连续的数列 我们枚 ...

  8. SRM 584 第一次玩TopCoder。。。只水题一道。。。

    第一次topcoder,以前老感觉没有资格去做tc,cf什么的,现在已经慢慢接触了. 感觉还可以,还是有让我们这些蒻菜安慰的水题. tc的确很好玩,用客户端比赛,还有各种规则,而且还是只编写一个类提交 ...

  9. SRM 638 Div2

    2333... 因为TC过少的参与者.加上不断fst 我掉了div2该. 幸运的是完成的背div1该.. 250 水的问题 500 水的问题.. 直接bfs扩展即可了 注意判重.  我还用康托展开了真 ...

随机推荐

  1. OpenRisc-48-or1200的SPRS模块分析

    引言 之前,我们在分析or1200的WB模块时(http://blog.csdn.net/rill_zhen/article/details/10220619),介绍了OpenRISC的GPRS(ge ...

  2. Jquery html页面处理基础

    1.怎样获得浏览器的可视高度?   var windHight = $(window).height(); //获得浏览器的可视高度 2.怎样获得滚动条相对于顶部的高度?   var scrollHi ...

  3. SQL分类取每一类第一项

    实际应用中经常会碰到这样的需求,在给定的数据集中要求返回每一类型中最大的一条,抑或是最小的一条,抑或是按时间排序最近的一条等等.很多人面对这样的需求显得束手无策,其实这个需求实现有很多种方法,今天给大 ...

  4. 复习day12-23

    获取请求中的内容: request.getParameter(); get方式因为在地址栏所以需要转码: String name = new String(req.getparameter().get ...

  5. 矩形嵌套(LIS)

    矩形嵌套 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 有n个矩形,每个矩形可以用a,b来描述,表示长和宽.矩形X(a,b)可以嵌套在矩形Y(c,d)中当且仅当a& ...

  6. OAuthBase.cs

    using System; using System.Security.Cryptography; using System.Collections.Generic; using System.Tex ...

  7. ssh框架用JUnit测试

    public class testAuxDict { //读spring配置文件 public static BeanFactory factory = new ClassPathXmlApplica ...

  8. Oracle EBS 如何月结、对账[Z]

    在Oracle系统处理月结业务时,需要遵循一定的操作顺序.这些业务,牵涉到相应的模块,包括:应付模块.采购模块.库存模块.应收模块.薪资模块.固定资产和总帐模块等 在Oracle系统中,总帐模块处于财 ...

  9. day8_python学习笔记_chapter11_函数

    1. 返回对象的数目   python实际返回的对象 0 -> None ; 1 -> object ; >1 -> tuple 2. 内部/内嵌函数:如果内部函数的定义包含了 ...

  10. GO语言搭建

    最近对GO语言产生了浓厚的兴趣.因为GO语言不仅仅可以开发桌面.web程序,最吸引我的是安卓大有往GO语言全方位靠拢的趋势,自家的系统还是用自家的语言开发比较靠谱. 用一句话来说:Go语言是谷歌200 ...