Codeforces Round #253 (Div. 2)——Borya and Hanabi
- 题意:
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的更多相关文章
- Codeforces Round 253 (Div. 2)
layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- Codeforces Round #253 (Div. 1) (A, B, C)
Codeforces Round #253 (Div. 1) 题目链接 A:给定一些牌,然后如今要提示一些牌的信息,要求提示最少,使得全部牌能够被分辨出来. 思路:一共2^10种情况,直接暴力枚举,然 ...
- 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 ...
- 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 ...
- Codeforces Round #253 (Div. 2) D. Andrey and Problem
关于证明可以参考题解http://codeforces.com/blog/entry/12739 就是将概率从大到小排序然后,然后从大到小计算概率 #include <iostream> ...
- 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- ...
- Codeforces Round #253 (Div. 2) B - Kolya and Tandem Repeat
本题要考虑字符串本身就存在tandem, 如测试用例 aaaaaaaaabbb 3 输出结果应该是8而不是6,因为字符串本身的tanderm时最长的 故要考虑字符串本身的最大的tanderm和添加k个 ...
- Codeforces Round #253 (Div. 2) A. Anton and Letters
题目很简单,只需要注意带空格的输入用getline即可 #include <iostream> #include <vector> #include <algorithm ...
- Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】
简易字符串匹配,题意不难 #include <stdio.h> #include <string.h> #include <math.h> #include < ...
随机推荐
- 九度oj 题目1159:坠落的蚂蚁
题目描述: 一根长度为1米的木棒上有若干只蚂蚁在爬动.它们的速度为每秒一厘米或静止不动,方向只有两种,向左或者向右.如果两只蚂蚁碰头,则它们立即交换速度并继续爬动.三只蚂蚁碰头,则两边的蚂蚁交换速度, ...
- Java&Android代码规范
项目中直接导入Square的代码风格文件.(不导入Google的原因是Square同时提供了Java和Android两套统一风格,Google只提供了一套) Square Code Styles Go ...
- LogMiner配置使用手册
LogMiner配置使用手册 1 Logminer简介 1.1 LogMiner介绍 Oracle LogMiner 是Oracle公司从产品8i以后提供的一个实际非常有用的分析工具,使用该工具可以轻 ...
- 【DFS求树的最大二分匹配+输入外挂】HDU 6178 Monkeys
http://acm.hdu.edu.cn/showproblem.php?pid=6178 [题意] 给定一棵有n个结点的树,现在有k个猴子分布在k个结点上,我们可以删去树上的一些边,使得k个猴子每 ...
- 在echars上发布的半圆环形图
http://gallery.echartsjs.com/editor.html?c=xBJvoMcPfz&v=1
- Java 模板权重随机
Template templates=...// 所有的模板 final int _weights=1000; // 所有的模板权重 Template _template=null; //随机一个权重 ...
- [转]JVM 堆内存设置原理
堆内存设置 原理 JVM堆内存分为2块:Permanent Space 和 Heap Space. Permanent 即 持久代(Permanent Generation),主要存放的是Java类定 ...
- route命令走一波
1.写文章去了解某个命令完全是兴起,并没有下定决心去学哪一套课程,目前的状态仍然是犹豫中,废话不多说进入正文,九月二十七这天看到了route命令,发现对路由这个命令很陌生,陌生到根本不知道它是用来干什 ...
- js中的offsetParent,offsetLeft,offsetTop及jquery的offset(),position()比较
1.offsetParent 元素的offsetParent并不是元素的父元素,判断元素的offsetParent要根据以下情况: 1)当DOM结构层次中的元素均没有进行css定位(设置positio ...
- FFT/NTT模板 既 HDU1402 A * B Problem Plus
@(学习笔记)[FFT, NTT] Problem Description Calculate A * B. Input Each line will contain two integers A a ...