250pt

在一个10^9 * 10^9大的剧院里,有最多47个位子有人,然后有一对couple想找一对左右相邻的位子,问有多少种选择方式。

思路:

总共有 n * (m-1)种方案,然后扣掉有人位置占掉的方案即可。

这里占掉位置我用一个set存储,正好可以去重。。

 #line 7 "TheMoviesLevelOneDivOne.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII; class TheMoviesLevelOneDivOne
{
public:
long long find(int n, int m, vector <int> row, vector <int> seat)
{
long long ans = n;
ans =ans * (m - );
set< PII > S;
for (int i = ; i < row.size(); ++i){
if (seat[i] > ) S.insert(make_pair(row[i], seat[i]));
if (seat[i] + <= m) S.insert(make_pair(row[i], seat[i] + ));
}
ans -= S.size();
return ans;
} };

500pt

题意:一个人看电影,该人有一个scare值,并且没看1min电影scare减1。有很多部恐怖电影,每部电影长度不同(length[i]),且每部都有一个瞬间增加scare(s[i])值的时刻。如果scare值小于0,则这个人就会睡着,不能再看电影。请问他安排一个电影观看顺序,使得他能看尽可能多的电影。如果有多组观看顺序看到的电影数相同,则输出字典序最小的。(电影数量小等于20)

思路:

状态压缩。。

 #line 7 "TheMoviesLevelTwoDivOne.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
int dp[ << ]; class TheMoviesLevelTwoDivOne
{
public:
vector <int> find(vector <int> L, vector <int> scary)
{
int n = L.size();
memset(dp, , sizeof(dp));
for (int i = ; i < ( << n); ++i){
int level = ;
for (int j = ; j < n; ++j)
if (!(i & ( << j))) level += - L[j];
for (int j = ; j < n; ++j) if (i & ( << j))
if (level >= scary[j] && level + - L[j] >= )
dp[i] = max(dp[i], dp[i ^ ( << j)] + );
}
vector<int> ans;
int x = , mask = ( << n) - ;
while (mask > ){
for (int i = ; i < n; ++i) if (mask & ( << i))
if (dp[mask] == ||
(x >= scary[i] && x + - L[i] >= && dp[mask ^ ( << i)] == dp[mask] - )){
ans.PB(i);
mask ^= ( << i);
x += - L[i];
break;
}
}
return ans;
}
};

SRM469的更多相关文章

  1. SRM468 - SRM469(1-250pt, 500pt)

    SRM 468 DIV1 250pt 题意:给出字典,按照一定要求进行查找. 解法:模拟题,暴力即可. tag:water score: 0.... 这是第一次AC的代码: /* * Author: ...

  2. Topcoder 好题推荐

    SRM SRM147 DIV1 1000pt DP SRM148 DIV1 1100pt 递归 SRM149 DIV1 1000pt math SRM150 DIV1 500pt DP SRM469 ...

随机推荐

  1. hdu 1175(BFS&DFS) 连连看

    题目在这里:http://acm.hdu.edu.cn/showproblem.php?pid=1175 大家都很熟悉的连连看,原理基本就是这个,典型的搜索.这里用的是广搜.深搜的在下面 与普通的搜索 ...

  2. OpenSource.SerializationLibrary

    1. Cap'n Proto protocol buffer的主要作者之一创建的新项目.其主页描述Cap'n Proto的性能比PB快很多. http://kentonv.github.io/capn ...

  3. Luogu2022 有趣的数-二分答案+数位DP

    Solution 我好像写了一个非常有趣的解法233, 我们可以用数位$DP$ 算出比$N$小的数中 字典序比 $X$ 小的数有多少个, 再和 $rank$进行比较. 由于具有单调性, 显然可以二分答 ...

  4. Javascript的一个怪现象

    javascript有一个怪现象,就是减法也会导致小数位数问题,是一个麻烦的问题,比如. <html><script> var a=10,b=20.1; alert( a - ...

  5. 在linux虚拟机上安装Docker

    1.简介Docker是一个开源的应用容器引擎:是一个轻量级容器技术: Docker支持将软件编译成一个镜像:然后在镜像中各种软件做好配置,将镜像发布出去,其他使用者可以直接使用这个镜像: 运行中的这个 ...

  6. springboot配置il8n

    springMvc下,配置il8n: 1.配置ResourceBundleMessageSource管理国际化资源文件 2.在页面使用fmt标签取出国际化内容 springBoot下,自动配置了il8 ...

  7. 【WebService】使用JDK开发WebService(二)

    WebService的开发手段 1.使用JDK开发(1.6及以上版本) 2.使用CXF框架开发(工作中) WebService的组成 1.服务器端 2.客户端 使用JDK开发WebService a. ...

  8. [C#.net]WinForm载入窗体完成后自动执行事件

    一.以下是网络上可搜索到的次序 当 Windows Form 应用程序启动时,会以下列顺序引发主要表单的启动事件:        System.Windows.Forms.Control.Handle ...

  9. mysqldb mysql_config

    在安装mysqldb Python的时候会用到mysql_config,但是正常安装的MySQL环境下是没有这个文件的,这个文件在Linux下是可执行文件,所以需要到mysql官方网站上下载MySQL ...

  10. 2018.10.31 bzoj3339&&3585mex(主席树)

    传送门 双倍经验 直接上主席树,每个叶节点维护这个值出现的最右区间,非叶子节点维护当前值域内所有最右区间的最小值. 查询的时候只用在以root[qr]root[qr]root[qr]为根的树上面二分. ...