Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define pf push_front
- #define mp make_pair
- #define sz size
- #define ll long long
- #define ld long double
- #define fs first
- #define sc second
- #define forn(i, f, t) for(int i = f; i < t; i++)
- #define all(x) (x).begin(), (x).end()
- #define ins insert
- const int INF = 2147483647;
- const int MOD = 1000000007;
- const ll INF64 = 9223372036854775807;
- const ld EPS = 1e-7;
- using namespace std;
- int check(const vector<int> &a, const vector<int> &b){
- int cur = 0;
- forn(i, 0, 6) cur += (a[i] == b[i]);
- return max(0, (6 - cur) / 2 + (6 - cur) % 2 - 1);
- }
- int main(){
- int n, t;
- scanf("%d", &n);
- vector<int> a[n];
- forn(i, 0, n){
- scanf("%d", &t);
- int k = 100000;
- while (k){
- a[i].pb(t / k);
- t %= k;
- k /= 10;
- }
- }
- int ans = 6;
- forn(i, 0, n) forn(j, i + 1, n) ans = min(ans, check(a[i], a[j]));
- printf("%d\n", ans);
- return 0;
- }
Add Comment
Please, Sign In to add comment