Codeforces Round #253 (Div. 1) A Borya and Hanabi
2 seconds
256 megabytes
standard input
standard output
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.
Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding
n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards except for Borya himself. Borya knows which cards he has but he knows nothing about the order they lie in. Note that Borya can have
multiple identical cards (and for each of the 25 types of cards he knows exactly how many cards of this type he has).
The aim of the other players is to achieve the state when Borya knows the color and number value of each of his cards. For that, other players can give him hints. The hints can be of two types: color hints and value hints.
A color hint goes like that: a player names some color and points at all the cards of this color.
Similarly goes the value hint. A player names some value and points at all the cards that contain the value.
Determine what minimum number of hints the other players should make for Borya to be certain about each card's color and value.
The first line contains integer n (1 ≤ n ≤ 100) — the number of Borya's cards. The next line contains the descriptions of
n cards. The description of each card consists of exactly two characters. The first character shows the color (overall this position can contain five distinct letters — R, G, B, Y, W). The second character shows the card's
value (a digit from 1 to 5). Borya doesn't know exact order of the cards they lie in.
Print a single integer — the minimum number of hints that the other players should make.
2
G3 G3
0
4
G4 R4 R3 B3
2
5
B1 Y1 W1 G1 R1
4
In the first sample Borya already knows for each card that it is a green three.
In the second sample we can show all fours and all red cards.
In the third sample you need to make hints about any four colors.
Codeforces Round #253 (Div. 1) A Borya and Hanabi的更多相关文章
- 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. 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. 2)——Borya and Hanabi
题目连接 题意: n表示有n个卡片.每一个卡片有一种颜色和一个数字(共五种不同的颜色和五个不同的数字). 事先知道每种卡片有几张.可是不知道详细的位置. 问须要几次提示就能够知道全部卡片的位置都在哪里 ...
- 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 < ...
随机推荐
- css内容补充之其它
1.overflow 当图片大小,超出div的大小时,可以指定overflow值为auto(带滚动条).hidden(隐藏,只显示一块): hover 当鼠标移动到当前标签上时,以下css属性才生效:
- android 图片
1,setCompoundDrawables(Drawable left, Drawable top,Drawable right, Drawable bottom) 设置图片出现在textView, ...
- 左右分栏页面右侧无法出现滚动条bug
问题记录 项目比较老了,左右分栏的页面,导航栏右边是一个iframe组成的页面,通过某个操作后,页面右侧内容区域无法实现滚动 问题查明 遇见过好几次,最后查明,总结一句话,修改了右侧页面body的ov ...
- c++类的单目和双目运算符的重定义
这个里面需要注意的是对于双目运算符,像是加号,如果是复数加整数是一种情况,而整数加复数又是另一种情况,所以需要重定义两次. 而对于单目运算符,如果是前缀的,直接重定义就可以了,但是如果是后缀的,我们在 ...
- C#对象初始化的探讨
最近在弄MQ的性能监测数据埋点,无疑中用到一个Nstatsd的客户端,看到里面写过里面一种嵌套类的写法.代码如下: 客户端Client是一个密封的类,并且构造函数私有访问.然后又用一个嵌套类Curre ...
- 编写一个微信小程序
1.创建项目 2.创建目录及文件,结构如下:
- css 实践记录
子绝父相 https://developer.mozilla.org/zh-CN/docs/Web/CSS/position 利用子绝父相来实现一种比较老的居中方式:1.明确宽度:2.定位左边到容器的 ...
- Oracle中exit,return,continue
记录exit和return的用法 exit用来跳出循环 loop IF V_KBP IS NULL THEN EXIT; END IF; end loop; return跳出 ...
- python基础——7(函数)
一.函数的定义(函数一定是先定义,后引用) 函数是完成特定功能的代码块. def:声明函数的关键字 fun:函数变量名 ():参数列表,参数可以是0-n个,但是()不能丢 函数体:实现功能的具体代码 ...
- idea 中使用 出现 svn: E155036
在idea中使用svn checkout时 svn出现如上错误. 原因本地的工作副本太旧.command line进入本地工作副本的根目录,执行svn upgrade后 重启idea就可以了.