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的更多相关文章

  1. Codeforces #367 (Div. 2) D. Vasiliy's Multiset (trie 树)

    http://codeforces.com/group/1EzrFFyOc0/contest/706/problem/D 题目:就是有3种操作 + x向集合里添加 x - x 删除x元素,(保证存在 ...

  2. CodeForces #367 div2 D Trie

    题目链接:Vasiliy's Multiset 题意:这里有一个set容器,有三种操作,+ num, - num, ? num,分别代表往容器里加上num,或者拿走num,或着从容器里找一个数temp ...

  3. CodeForces #367 div2 C

    题目链接: Hard problem 题意:每个字符串可以选择反转或者不反转,给出反转每个字符串的代价,问使最少的代价使得这个字符串序列成字典序. dp[i][j] = x : 第一维是第i个字符串, ...

  4. CodeForces 367 C Sereja and the Arrangement of Numbers 欧拉回路

    Sereja and the Arrangement of Numbers 题解: ummm. 在一副图中,如果全部点的度数是偶数/只有2个点是奇数,则能一笔画. 考虑图的点数k为奇数的时候,那么每个 ...

  5. 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 ...

  6. Codeforces Round #367 (Div. 2) C. Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

  7. Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)

    Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...

  8. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  9. trie树 Codeforces Round #367 D Vasiliy's Multiset

    // trie树 Codeforces Round #367 D Vasiliy's Multiset // 题意:给一个集合,初始有0,+表示添加元素,-去除元素,?询问集合里面与x异或最大的值 / ...

随机推荐

  1. C++ 打印输出指针

    大家想必在很多场景下需要打印输出指针地址.看一下下面的输出:       CObject* pObject = new CObject;     std::cout << pObject  ...

  2. SQL中存储过程和自定义函数的区别

    存储过程:     存储过程可以使得对数据库的管理.以及显示关于数据库及其用户信息的工作容易得多.存储过程是 SQL 语句和可选控制流语句的预编译集合,以一个名称存储并作为一个单元处理.存储过程存储在 ...

  3. 百度地图api经纬度气死我了!

      百度地图api经纬度气死我了! 百度地图官网api中例子的经纬度.我测试了2天才好用.一直是不能用.坑死我了.原来是获取的经纬度.和实际调用的经纬度尽然是反的.调转过来就好用了.气死我了.弄了两天 ...

  4. 如何使java中double类型不以科学计数法表示

    在java中,把一个double或者BigDecimal的小数转换为字符串时,经常会用科学计数法表示,而我们一般不想使用科学计数法,可以通过:DecimalFormat a = new Decimal ...

  5. kindeditor编辑器图片水印

    //upload_pic.ashx源码 <%@ webhandler Language="C#" class="edit_html_upload_pic" ...

  6. 手动配置gradle

    最近从github倒入项目,运行的特别慢gradle配置有问题,解决方法: 1.C:\android\demo\hellocharts-android-master\gradle\wrapper 目录 ...

  7. Java [Leetcode 94]Binary Tree Inorder Traversal

    题目描述: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given bina ...

  8. 【C#学习笔记】检测进程是否存在并关闭

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. 一天一个Java基础——序列化

    1.概念 Java的“对象序列化”能将一个实现了Serializable接口的对象转换成一组byte,这样日后要用这个对象的时候,能把这些byte数据恢复出来,并据此重新构建那个对象. 对象序列化能实 ...

  10. 【又见LCS】NYOJ-37 回文字符串

    [题目链接] 回文字符串 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba& ...