题目连接

  • 题意:

    n表示有n个卡片。每一个卡片有一种颜色和一个数字(共五种不同的颜色和五个不同的数字)。

    事先知道每种卡片有几张。可是不知道详细的位置。

    问须要几次提示就能够知道全部卡片的位置都在哪里:每次提示能够选择一个颜色或者一个数字。就能够知道含有所选属性的牌有哪些。

  • 分析:

    首先明确总情况数不多,仅仅有2^10,所以枚举。

    能确定某张牌位置的情况:1)提示了一个属性,而这个属性仅仅有一张牌 2)某个属性有n张牌,知道了n-1张牌的位置

    两个提示确定一张牌:必定的,仅仅要存在这张牌。那么两个提示必定能够找到相应的牌的位置

    一个提示就能够确定某张牌的情况:此时这张牌的还有一个属性在总的集合中必定仅仅有一个

  • 关键:

    全部同样的卡片仅仅用保留一个就可以
set<int> st[10];
int all = 1 << 10, ans = INF; int change(char x)
{
if (x == 'B') return 0;
else if (x == 'Y') return 1;
else if (x == 'W') return 2;
else if (x == 'G') return 3;
else return 4; //R
}
void fun(int num, set<int> st[])
{
int one = 0, t[10] = {0};
for (int j = 1, ct = 0; j < all; j <<= 1, ct++)
if (num & j)
{
one++;
t[ct] = 1;
}
REP(i, 5) FF(j, 5, 10)
if (t[i] && t[j])
{
st[i].erase(j);
st[j].erase(i);
}
REP(i, 10)
if (t[i] && st[i].size() == 1)
{
st[*(st[i].begin())].erase(i);
st[i].clear();
}
int len = 0;
REP(i, 5) len += st[i].size();
if (len <= 1)
ans = min(ans, one);
}
int main()
{
int n;
char x; int y;
cin >> n;
REP(i, n)
{
cin >> x >> y;
st[change(x)].insert(y + 4);
st[y + 4].insert(change(x));
}
FF(i, 0, all)
{
set<int> tt[10];
REP(j, 10) tt[j] = st[j];
fun(i, tt);
}
WI(ans);
return 0;
}

Codeforces Round #253 (Div. 2)——Borya and Hanabi的更多相关文章

  1. Codeforces Round 253 (Div. 2)

    layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  2. Codeforces Round #253 (Div. 1) (A, B, C)

    Codeforces Round #253 (Div. 1) 题目链接 A:给定一些牌,然后如今要提示一些牌的信息,要求提示最少,使得全部牌能够被分辨出来. 思路:一共2^10种情况,直接暴力枚举,然 ...

  3. Codeforces Round #253 (Div. 1) A. Borya and Hanabi 暴力

    A. Borya and Hanabi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/442/p ...

  4. Codeforces Round #253 (Div. 1) A Borya and Hanabi

    A. Borya and Hanabi time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #253 (Div. 2) D. Andrey and Problem

    关于证明可以参考题解http://codeforces.com/blog/entry/12739 就是将概率从大到小排序然后,然后从大到小计算概率 #include <iostream> ...

  6. Codeforces Round #253 (Div. 2) D题

    题目大意是选出一个其他不选,问问最大概率: 刚开始想到DP:F[I][J][0]:表示从 前I个中选出J个的最大值, 然后对于F[I][J][1]=MAX(F[I-1][J][1],F[I-1][J- ...

  7. Codeforces Round #253 (Div. 2) B - Kolya and Tandem Repeat

    本题要考虑字符串本身就存在tandem, 如测试用例 aaaaaaaaabbb 3 输出结果应该是8而不是6,因为字符串本身的tanderm时最长的 故要考虑字符串本身的最大的tanderm和添加k个 ...

  8. Codeforces Round #253 (Div. 2) A. Anton and Letters

    题目很简单,只需要注意带空格的输入用getline即可 #include <iostream> #include <vector> #include <algorithm ...

  9. Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】

    简易字符串匹配,题意不难 #include <stdio.h> #include <string.h> #include <math.h> #include < ...

随机推荐

  1. 【LeetCode】To Lower Case(转换成小写字母)

    这道题是LeetCode里的第709道题. 题目要求: 实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串. 示例 1: ...

  2. 九度oj 题目1537:买卖股票

    题目描述: 给定一个大小为n的数组,数组的元素a[i]代表第i天的股票价格. 设计一个算法,计算在最多允许买卖k次(一买一卖记为一次)的条件下的最大收益. 需要注意的是,你不能同时拥有两份股票.也就是 ...

  3. Title共通写法

    用: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_c ...

  4. 【Android】监听viewpager子页面里面的Button按钮

    最近做项目遇到Viewpager+Fragment滑动页面,要监听子页面中的按钮,在网上查了些解决办法: 办法一: 这种方法是在适配器初始化中进行监听,有人亲测通过,但是我继承FragmentPage ...

  5. NYOJ——239月老的难题(二分图最大匹配)

    月老的难题 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 月老准备给n个女孩与n个男孩牵红线,成就一对对美好的姻缘. 现在,由于一些原因,部分男孩与女孩可能结成幸福的一家, ...

  6. BZOJ 3669 [Noi2014]魔法森林 ——SPFA / Link-Cut Tree

    [题目分析] 大意就是有一张图,边权有两个值,ai和bi 找到一条路径,使得路径上的max(ai)+max(bi)最小. 遇到有两个权值或者多个权值的时候,如果他们互相影响,试着用分块搞一搞. 如果互 ...

  7. 论文笔记:Ten years of pedestrian detection, what have we learned?

    最近正在研究行人检测,学习了一篇2014年发表在ECCV上的一篇综述性的文章,是对行人检测过去十年的一个回顾,从dataset,main approaches的角度分析了近10年的40多篇论文提出的方 ...

  8. phoenixframework集成了所有自动化测试的思想的平台。mark一下。

    phoenixframework http://www.cewan.la/

  9. intellij idea 使用用到的问题

    1.github error setting certificate verify locations使用github时报错,解决方法: git config --system http.sslcai ...

  10. 【Hihocoder1034】毁灭者问题(splay,树状数组)

    题意: 假设你拥有 n 个魔法单位,他们从左到有站在一行,编号从 1 到 n. 每个单位拥有三项属性: si: 初始法力. mi: 最大法力上限. ri: 每秒中法力回复速度. 现在你操纵一个毁灭者, ...