早早地水完了三道题,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. Oracle EBS-SQL (BOM-10):检查有BOM无计划员的数据.sql

    select DISTINCT     msi.segment1 编码    ,msi.description 描述    ,msi.item_type 物料类型    ,msi.inventory_ ...

  2. SPI Flash

    使用了MX25L512的SPI接口的Flash 电路连接图: 总的大小512kb,即64kB,sector的大小为256 Bytes,block的大小为4k Bytes 调试时出现的问题: 1.Fla ...

  3. ajax跨域请求的方案

    $.get("@Hosts.Default.Www/api/XXXXX/Getxxx/"+@Model.UserId, function(data) { $("#tota ...

  4. CSS制作出绚丽燃烧的火狐狸

    From here:http://www.webhek.com/firefox-animation/ ozilla在移动世界大会上宣布它的火狐操作系统(Firefox OS)的同时,也宣布了它的合作伙 ...

  5. html和js

    1.<input type="button" value="Hello world!"> 2.<button type="butto ...

  6. Android Activity 启动模式详解

    最近有群里的朋友问我 Activity的四种启动模式分别是什么意思? 当初因为项目比较忙,草草的解释了下, Api文档中说的也只是一般,在这里就小记一下吧,以便有更多的朋友对Activity启动模式了 ...

  7. Android UI SurfaceView的使用-绘制单个图型或多个图形

    新建MyView类继承自SurfaceView: public class MyView extends SurfaceView implements SurfaceHolder.Callback { ...

  8. 利用ItextPdf、core-renderer-R8 来生成PDF

    近期因为工作上的须要,须要做一个简历产品的下载功能,而下载的形式要去为PDF,内容要求为整个简历的内容,并且格式上要求和简历的格式排版时一致的!前期调研.开发,最后測试上线.差点儿相同花了7天的时间. ...

  9. 如何使用eclipse生成javadoc帮助文档

    ---恢复内容开始--- 如果你已经能制造轮子了,你想让其他人使用你的轮子,那你就得告诉他们你的轮子都是由什么构成的.这样他们才能更好的使用你制造的轮子.然而,很多开发者都不想写长篇大论的帮助文档,这 ...

  10. Java SE基础部分——常用类库之NumberFormat(数字格式化)

    数字格式化常用方法:DecimalFormat和NuberFormat. //2016060524 数字格式化学习 //数字格式化 两种方法 一种直接使用NumberFormat,另一种Decimal ...