VK Cup 2016-Qualification Round 1(Russian-speaking Only,for VK Cup teams)C.
제목 연결:
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
제목
6 개의 숫자 만 들 어 있 는 꼬치 n 개 드릴 게 요.
그리고 지금 그들 은 한 가지 물건 을 규정 했다.만약 에 이 두 꼬치 가 k 개 보다 작은 위치 만 다 르 면 똑 같다 고 생각한다.
다음 n 개의 꼬치 를 다 르 게 해 야 하 는 k 를 규정 하 십시오.
출력 이 가장 큰 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;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.