PikMike

Untitled

Mar 13th, 2016
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define pb push_back
  4. #define pf push_front
  5. #define mp make_pair
  6. #define sz size
  7. #define ll long long
  8. #define ld long double
  9. #define fs first
  10. #define sc second
  11. #define forn(i, f, t) for(int i = f; i < t; i++)
  12. #define all(x) (x).begin(), (x).end()
  13. #define ins insert
  14.  
  15. const int INF = 2147483647;
  16. const int MOD = 1000000007;
  17. const ll INF64 = 9223372036854775807;
  18. const ld EPS = 1e-7;
  19.  
  20. using namespace std;
  21.  
  22. int check(const vector<int> &a, const vector<int> &b){
  23.     int cur = 0;
  24.     forn(i, 0, 6) cur += (a[i] == b[i]);
  25.     return max(0, (6 - cur) / 2 + (6 - cur) % 2 - 1);
  26. }
  27.  
  28.  
  29. int main(){
  30.     int n, t;
  31.     scanf("%d", &n);
  32.     vector<int> a[n];
  33.     forn(i, 0, n){
  34.         scanf("%d", &t);
  35.         int k = 100000;
  36.         while (k){
  37.             a[i].pb(t / k);
  38.             t %= k;
  39.             k /= 10;
  40.         }
  41.     }
  42.     int ans = 6;
  43.     forn(i, 0, n) forn(j, i + 1, n) ans = min(ans, check(a[i], a[j]));
  44.     printf("%d\n", ans);
  45.     return 0;
  46. }
Add Comment
Please, Sign In to add comment