Codeforces 367
A. Sereja and Algorithm
水题不解释。
B. Sereja ans Anagrams
模p同余的为一组,随便搞。
C. Sereja and the Arrangement of Numbers
我还以为是找规律。。。
把每个数当成一个点。就有一个图。让后求欧拉路什么的。
D. Sereja and Sets
这个思路感觉很巧妙(可能是我太弱了),我们对于每一段连续的d,找到不包含它们的所有集合,这些集合的子集一定不可行。
见代码。
/*
* Problem: D. Sereja and Sets
* Author: Shun Yao
*/ #include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <time.h> #include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <utility>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> //using namespace std; int n, m, d, bad[1 << 21], s[100010], cnt[25]; int main(/*int argc, char **argv*/) {
int i, j, k, l, tmp, ans; scanf("%d%d%d", &n, &m, &d);
for (i = 0; i < m; ++i) {
scanf("%d", &j);
for (k = 0; k < j; ++k) {
scanf("%d", &l);
s[l - 1] = i;
}
}
memset(bad, 0, sizeof bad);
for (i = 0; i < n; ++i) {
if (i >= d)
--cnt[s[i - d]];
++cnt[s[i]];
if (i >= d - 1) {
tmp = 0;
for (j = 0; j < m; ++j)
if (!cnt[j])
tmp += 1 << j;
bad[tmp] = 1;
}
}
ans = 21;
for (i = (1 << m) - 1; i >= 0; --i) {
if (!bad[i]) {
k = i;
l = 0;
while (k) {
++l;
k -= k & -k;
}
ans = std::min(ans, l);
} else {
k = i;
while (k) {
l = k & -k;
bad[i - l] = 1;
k -= l;
}
}
}
printf("%d", ans); fclose(stdin);
fclose(stdout);
return 0;
}
E. Sereja and Intervals
问题是求n个互不包含的区间且其中一个区间的左端是x的方案数。(原题n个区间排列也算不同方案,为了方便思考我们可以考虑排列算相同方案,然后让结果成以n的阶乘。
f[i][j][k]代表目前到i,有左端点j个,右端点k个的合法方案数。(好像还有其他的状态定义,也可以做)
Codeforces 367的更多相关文章
- Codeforces #367 (Div. 2) D. Vasiliy's Multiset (trie 树)
http://codeforces.com/group/1EzrFFyOc0/contest/706/problem/D 题目:就是有3种操作 + x向集合里添加 x - x 删除x元素,(保证存在 ...
- CodeForces #367 div2 D Trie
题目链接:Vasiliy's Multiset 题意:这里有一个set容器,有三种操作,+ num, - num, ? num,分别代表往容器里加上num,或者拿走num,或着从容器里找一个数temp ...
- CodeForces #367 div2 C
题目链接: Hard problem 题意:每个字符串可以选择反转或者不反转,给出反转每个字符串的代价,问使最少的代价使得这个字符串序列成字典序. dp[i][j] = x : 第一维是第i个字符串, ...
- CodeForces 367 C Sereja and the Arrangement of Numbers 欧拉回路
Sereja and the Arrangement of Numbers 题解: ummm. 在一副图中,如果全部点的度数是偶数/只有2个点是奇数,则能一笔画. 考虑图的点数k为奇数的时候,那么每个 ...
- Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset (0/1-Trie树)
Vasiliy's Multiset 题目链接: http://codeforces.com/contest/706/problem/D Description Author has gone out ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...
- Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
- trie树 Codeforces Round #367 D Vasiliy's Multiset
// trie树 Codeforces Round #367 D Vasiliy's Multiset // 题意:给一个集合,初始有0,+表示添加元素,-去除元素,?询问集合里面与x异或最大的值 / ...
随机推荐
- WPF中Timer与DispatcherTimer类的区别
前几天在WPF中写了一个轨迹回放的功能,我想稍微做过类似项目的,都晓得采用一个时间控件或者时间对象作为调度器,我在这么做的时候,出现了问题,于是将程序中的Timer换成了DispatchTimer,然 ...
- [NYIST16]矩形嵌套(DP,最长上升子序列)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=16 像套娃一样把矩形套起来.先给矩形从小到大排序,然后做最长上升子序列就行 /* ━━━━ ...
- Mac下安装HBase及详解
Mac下安装HBase及详解 1. 千篇一律的HBase简介 HBase是Hadoop的数据库, 而Hive数据库的管理工具, HBase具有分布式, 可扩展及面向列存储的特点(基于谷歌BigTabl ...
- sql server删除数据后空间无变化处理方法
删除数据库表 第一步: 执行 delete from doc.115sou.com #删除数据,执行效率低 drop table doc.115sou.com #删除表 ...
- html5客户端跨域访问php服务端数据
客户端代码: var param = $.param( { feed:JSON.stringify({ content:'abcd' }) } ); $http({ url: 'http://61.1 ...
- VS2010下编译安装DarwinStreamingServer5.5.5
源码下载链接:http://dss.macosforge.org/源码版本: 5.5.5版本电脑环境:visual studio2010,window 7 x64系统.用VS2010打开WinNTSu ...
- jQuery实战读书笔记(备忘录)
选择器备忘: | :even 匹配所有索引值为偶数的元素,从 0 开始计数 :odd 匹配所有索引值为奇数的元素,从 0 开始计数 实例——设置table交替行变色: <script type= ...
- Log4NET简介
log4net库是Apache log4j框架在Microsoft .NET平台的实现,是一个帮助程序员将日志信息输出到各种目标(控制台.文件.数据库等)的工具. 前提 最近做项目需要记录系统日志和用 ...
- ubuntu鼠标突然不能使用的解决方法
今天发现鼠标(usb即插即用)不能用了,最后发现需要接通充电才可以!!!用电池的时候居然不可以用鼠标?
- executeQuery,executeUpdate 和 execute 区别
http://www.360doc.com/content/14/0315/09/16068204_360719186.shtml http://i-feng.iteye.com/blog/17066 ...