VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) C. Promocodes with Mistakes 水题
C. Promocodes with Mistakes
题目连接:
http://www.codeforces.com/contest/637/problem/C
Description
During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ.
As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum k, that the promotional code could be uniquely identified if it was typed with no more than k errors. At that, k = 0 means that the promotional codes must be entered exactly.
A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits.
Input
The first line of the output contains number n (1 ≤ n ≤ 1000) — the number of promocodes.
Each of the next n lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0".
Output
Print the maximum k (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most k mistakes.
Sample Input
2
000000
999999
Sample Output
2
Hint
题意
给你n个只含有6个数字的串。
然后现在他们规定了一个东西,如果这两个串只有小于等于k个位置不同,就认为是一样的。
现在要你规定一个k,使得下列的n个串都必须视作不同。
输出最大的k。
题解:
数据范围才1000,所以直接暴力就好了……
代码
#include<bits/stdc++.h>
using namespace std;
string s[1005];
int main()
{
    int n;scanf("%d",&n);
    int ans = 6;
    for(int i=0;i<n;i++)
        cin>>s[i];
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int tmp = 0;
            for(int k=0;k<6;k++)
                if(s[i][k]!=s[j][k])
                    tmp++;
            ans=min(ans,(tmp-1)/2);
        }
    }
    cout<<ans<<endl;
}VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) C. Promocodes with Mistakes 水题的更多相关文章
- VK Cup 2016 - Qualification Round 2 B. Making Genome in Berland
		今天在codeforces上面做到一道题:http://codeforces.com/contest/638/problem/B 题目大意是:给定n个字符串,找到最短的字符串S使得n个字符串都是这个字 ... 
- VK Cup 2016 - Qualification Round 2 D. Three-dimensional Turtle Super Computer 暴力
		D. Three-dimensional Turtle Super Computer 题目连接: http://www.codeforces.com/contest/638/problem/D Des ... 
- VK Cup 2016 - Qualification Round 2 C. Road Improvement dfs
		C. Road Improvement 题目连接: http://www.codeforces.com/contest/638/problem/C Description In Berland the ... 
- VK Cup 2016 - Qualification Round 2 B. Making Genome in Berland 水题
		B. Making Genome in Berland 题目连接: http://www.codeforces.com/contest/638/problem/B Description Berlan ... 
- VK Cup 2016 - Qualification Round 2 A. Home Numbers 水题
		A. Home Numbers 题目连接: http://www.codeforces.com/contest/638/problem/A Description The main street of ... 
- VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) D. Running with Obstacles 贪心
		D. Running with Obstacles 题目连接: http://www.codeforces.com/contest/637/problem/D Description A sports ... 
- VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) B. Chat Order 水题
		B. Chat Order 题目连接: http://www.codeforces.com/contest/637/problem/B Description Polycarp is a big lo ... 
- VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) A. Voting for Photos 水题
		A. Voting for Photos 题目连接: http://www.codeforces.com/contest/637/problem/A Description After celebra ... 
- VK Cup 2016 - Qualification Round 1——A. Voting for Photos(queue+map)
		A. Voting for Photos time limit per test 1 second memory limit per test 256 megabytes input standard ... 
随机推荐
- python简单爬虫(二)
			上一篇简单的实现了获取url返回的内容,在这一篇就要第返回的内容进行提取,并将结果保存到html中. 一 . 需求: 抓取主页面:百度百科Python词条 https://baike.baidu. ... 
- MongoDB之主从复制和副本集(四)
			简单主从复制 采用一主一从或一主多从的布署模式,可以将读写分离开来,提高数据库的可用性,不过mongodb的主从模式并不能在主节点崩溃后,从节点替换主节点的工作,一般可以在开发阶段使用. 实现步骤 设 ... 
- C++中string.find()函数,string.find_first_of函数与string::npos
			查找字符串a是否包含子串b,不是用strA.find(strB) > 0而是strA.find(strB) != string:nposstring::size_type pos = strA. ... 
- OAuth认证与授权
			什么是OAuth授权? 一.什么是OAuth协议 OAuth(开放授权)是一个开放标准. 允许第三方网站在用户授权的前提下访问在用户在服务商那里存储的各种信息. 而这种授权无需将用户提供用户名和密 ... 
- mysql 数据库备份及恢复
			1.备份 # 导出数据库:mysqldump -u 用户名 -p 数据库名 > 导出的文件名mysqldump -–add-drop-table -uusername -ppassword da ... 
- java并发编程实战笔记---(第四章)对象的组合
			4.1设计线程安全的类 包含三个基本要素: 1.找出构成对象状态的所有变量 2.找出约束状态变量的不变性条件 2.简历对象状态的并发访问管理策略 对象的状态: 域 基本类型所有域, 引用类型包括被引用 ... 
- 并发queue
			在并发队列上JDK提供了两套实现,一个是以ConcurrentLinkedQueue为代表的高性能队列,一个是以BlockingQueue接口为代表的阻塞队列,无论哪种都继承自Queue. 一.Con ... 
- 【前端笔记】浅谈js继承
			我们先想想我们用js最后要怎样实现面向对象的编程.事实上我们必须用上原型链这种东西. 我们的父类superType有属性和方法,并且一些能被子类subType继承,一些能被覆盖,但是丝毫不会影响到父类 ... 
- 洛谷P1482 Cantor表(升级版) 题解
			题目传送门 此题zha一看非常简单. 再一看特别简单. 最后瞟一眼,还是很简单. 所以在此就唠一下GCD大法吧: int gcd(int x,int y){ if(x<y) return gcd ... 
- css3代码整理—弹性盒子篇
			父级使用弹性盒子: #fu{ display:flex; } 父级中子级的对齐方式: 1.水平对齐方式:两端对齐 #fu { display:flex; justify-content:space-b ... 
