• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

VKCup2016-QualificationRound1(Russian-SpeakingOnly,forVKCupteams)C.Promocodeswit ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

题目连接:

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;
}

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++变量声明发布时间:2022-07-13
下一篇:
Hookexe和file通用C#DLL注入器injector(注入dll不限)发布时间:2022-07-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap