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. OneThink视图模型进行组合查询!文档组合文档详情

    测试方法:twoCate: public function twoCate(){ $where = array( 'category_id'=>43 ); $list = D('TwoView' ...

  2. 问答项目---金币经验奖励规则及网站配置写入config文件

    具体步骤: 引入配置文件——>获取当前数组——>进行合并 public function edit(){ //引入 config.php配置文件 $file = APP_PATH.'Com ...

  3. create sequence

    create sequence seq_test start with 3 increment by 1 minvalue 1  --范围-(1027 -1) maxvalue 99999999999 ...

  4. CentOS7 部署tomcat

    一.环境说明: 在 CentOS7下面部署tomcat7 . 二.tomcat部署 1.新建tomcat目录  mkdir tomcat 2.上传tomcat 安装文件   apache-tomcat ...

  5. sosi-statistics

    set echo offset scan onset lines 150set pages 66set verify offset feedback offset termout offcolumn ...

  6. talib 中文文档(十一):Cycle Indicator Functions 周期指标

    Cycle Indicator Functions 不是很懂,欢迎指教 HT_DCPERIOD - Hilbert Transform - Dominant Cycle Period 函数名:HT_D ...

  7. PROPAGATION_REQUIRES_NEW VS PROPAGATION_NESTED

    PROPAGATION_REQUIRES_NEW, in contrast to PROPAGATION_REQUIRED, uses a completely independent transac ...

  8. orcle中如何使用动态游标来对变量进行赋值

    在oracle中动态游标的概念一般不常用,但有时根据客户的特殊业务,需要使用到动态游标来解决问题!在对于一条动态SQL语句而产生多条记录时,动态游标的使用将是一个很好的选择,具体参见如下在工作流项目中 ...

  9. 204-React DOM 元素

    一.概述 为了提高性能和跨浏览器兼容性,React实现了一个独立于浏览器的DOM系统. 在React中,所有DOM属性和属性(包括事件处理程序)都应该是camelCased的.例如,HTML属性tab ...

  10. (转)Spring Boot中使用AOP统一处理Web请求日志

    AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是Spring框架中的一个重要内容,它通 ...