250pt:

水题set处理。

500pt:

题意:

给你一个图,每条边关联的两点为朋友,题目要求假设x的金钱为y,则他的左右的朋友当中的钱数z,取值为y - d <= z <= y + d.求使得任意两点的最大金钱差值,若果是inf输出-1.

思路:
求任意两点的最短的的最大值即可,比赛时不知道哪地方写搓了,直接被系统样例给虐了,老师这么悲剧500有思路能写,老师不仔细哎..

floyd求任意两点的最短距离好写一些。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue> #define CL(arr, val) memset(arr, val, sizeof(arr)) #define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)
#define ll __int64
#define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define keyTree (chd[chd[root][1]][0])
#define Read() freopen("din.txt", "r", stdin)
#define Write() freopen("dout.txt", "w", stdout); #define M 25000
#define N 207 using namespace std; const int inf = 0x7f7f7f7f;
const int mod = ; int f[N][N];
int n;
void floyd()
{
for (int k = ; k <= n; ++k)
{
for (int i = ; i <= n; ++i)
{
for (int j = ; j <= n; ++j)
{
if (f[i][k] != inf && f[k][j] != inf && f[i][j] > f[i][k] + f[k][j])
{
f[i][j] = f[i][k] + f[k][j];
}
}
}
} }
class Egalitarianism
{
public:
int maxDifference(vector <string> isF, int d)
{
n = isF.size();
for (int i = ; i <= n; ++i)
{
for (int j = ; j <= n; ++j) f[i][j] = inf;
}
for (int i = ; i < n; ++i)
{
for (int j = ; j < n; ++j)
{
if (isF[i][j] == 'Y')
{
f[i + ][j + ] = ;
}
}
}
floyd();
int Ma = ;
for (int i = ; i <= n; ++i)
{
for (int j = ; j <= n; ++j)
{
if (i == j) continue;
Ma = max(Ma,f[i][j]);
}
}
if (Ma == inf) return -;
else return Ma*d;
}
};

100pt:

题意:

有n个城市,给出每个城市的类型kind[i]表示i城市属于kind[i]类,然后给出已经发现的类型found[i]表示发现了found[i]类型, 然后给出k求满足有k个城市,并且这k个城市包含了m中已将发现的类型。(k个城市都是从已经发现的类型里面选的) 也即:知道m种数的每种数个数,然后将这些数放入K个箱子里面连,每个箱子只能放一个,要求放完后这k个箱子的数的种数为m

思路:
才开始想用组和公式方看看怎么放,可是那样考虑会有很多重复,而且不好去重。

dp其实很简单,可是就是想不到,弱逼的DP啊。  dp[i][j] 表示一共放了j个箱子,并且放了i种 则dp[i][j] += dp[i - 1][j - p]*c[found[i]][p];

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue> #define CL(arr, val) memset(arr, val, sizeof(arr)) #define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)
#define ll long long
#define L(x) (x) << 1
#define R(x) (x) << 1 | 1
#define MID(l, r) (l + r) >> 1
#define Min(x, y) (x) < (y) ? (x) : (y)
#define Max(x, y) (x) < (y) ? (y) : (x)
#define E(x) (1 << (x))
#define iabs(x) (x) < 0 ? -(x) : (x)
#define OUT(x) printf("%I64d\n", x)
#define lowbit(x) (x)&(-x)
#define keyTree (chd[chd[root][1]][0])
#define Read() freopen("din.txt", "r", stdin)
#define Write() freopen("dout.txt", "w", stdout); #define M 25000
#define N 107 using namespace std; const int inf = 0x7f7f7f7f;
const int mod = ;
ll dp[N][N];
ll c[][];
void init()
{
for (int i = ; i <= ; ++i)
{
c[i][i] = c[i][] = ;
}
for (int i = ; i <= ; ++i)
{
for (int j = ; j < i; ++j)
{
c[i][j] = c[i - ][j] + c[i - ][j - ];
}
}
}
class Excavations2
{
public:
int num[N]; long long count(vector <int> kind, vector <int> found, int K)
{
init();
int n = kind.size();
int m = found.size();
CL(num,); for (int i = ; i < n; ++i) num[kind[i]]++;
CL(dp,); dp[][] = ; for (int i = ; i < m; ++i)
{
for (int j = ; j <= K; ++j)
{
for (int p = ; p <= num[found[i]]; ++p)
{
if (j - p >= )
dp[i + ][j] += dp[i][j - p]*c[num[found[i]]][p];
}
}
}
return dp[m][K];
}
};

TC SRM 584 DIV2的更多相关文章

  1. TC SRM 584 DIV 2

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

  2. TC SRM 663 div2 B AABB 逆推

    AABB Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description One day, Jamie noticed that many En ...

  3. TC SRM 663 div2 A ChessFloor 暴力

    ChessFloor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description Samantha is renovating a squa ...

  4. TC SRM 665 DIV2 A LuckyXor 暴力

    LuckyXorTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 TC Description A lucky number is a positive int ...

  5. TC SRM 593 DIV2 1000

    很棒的DP,不过没想出,看题解了..思维很重要. #include <iostream> #include <cstdio> #include <cstring> ...

  6. TC SRM 591 DIV2 1000

    很不错的一题,非常巧妙的用DP顺序解决这个问题... 可以发现,只和A里面最小的有关系... #include <cstdio> #include <cstring> #inc ...

  7. tc srm 636 div2 500

    100的数据直接暴力就行,想多了... ac的代码: #include <iostream> #include <cstdio> #include <cstring> ...

  8. TC SRM 664 div2 B BearPlaysDiv2 bfs

    BearPlaysDiv2 Problem Statement    Limak is a little bear who loves to play. Today he is playing by ...

  9. TC SRM 664 div2 A BearCheats 暴力

     BearCheats Problem Statement    Limak is an old brown bear. Because of his bad eyesight he sometime ...

随机推荐

  1. {Azure} 常用链接

    https://azure.microsoft.com/zh-cn/documentation/scenarios/web-app/

  2. java的this表示当前类还是当前实例?

    转自:http://www.runoob.com/java/java-basic-syntax.html this 表示调用当前实例或者调用另一个构造函数

  3. 10.Curator队列

        Curator也提供ZK Recipe的分布式队列实现.利用ZK的 PERSISTENTSEQUENTIAL节点,可以保证放入到队列中的项目是按照顺序排队的.如果单一的消费者从队列中取数据,那 ...

  4. SELECT INTO 和 INSERT INTO SELECT

    做数据库开发的过程中难免会遇到有表数据备份的,而SELECT INTO……和INSERT INTO SELECT…… 这两种语句就是用来进行表数据复制,下面简单的介绍下: 1.INSERT INTO ...

  5. ZOJ 3209 Treasure Map(精确覆盖)

    Treasure Map Time Limit: 2 Seconds      Memory Limit: 32768 KB Your boss once had got many copies of ...

  6. spring boot tomcat 线程数 修改初始线程数 统计性能 每百次请求耗时

    [root@f java]# tail -30 nohup.outsearchES-TimeMillisSpent:448P->1602@fT->http-nio-8080-exec-3t ...

  7. python的pip的配置文件路径在哪里?如何修改pypi源?

    官方文档: https://pip.pypa.io/en/stable/user_guide/#configuration 举个例子: Windows用户想要更改pypi源,可以在%APPDATA%目 ...

  8. Python开发【数据结构】:算法(二)

    堆排序 1.—树与二叉树简介 树是一种数据结构 比如:目录结构 树是一种可以递归定义的数据结构 树是由n个节点组成的集合: 如果n=0,那这是一棵空树: 如果n>0,那存在1个节点作为树的根节点 ...

  9. NGINX:sticky模块实现基于cookie的负载均衡

    Sticky模块 简述: 之前公司部署了一套网站及时发布系统,架构如下图所示:Nginx做前端代理,发布系统用tomcat运行,一台共享存储,一台数据库服务器:由于网站及时发布系统涉及到了用户登录操作 ...

  10. centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课

    centos  shell脚本编程2 if 判断  case判断   shell脚本中的循环  for   while   shell中的函数  break  continue  test 命令   ...