aboutsummaryrefslogtreecommitdiff
path: root/10_advanced_techniques/hamming_distance_2136.cpp
blob: a4b0b7d1b7ce07e1fb3060a068c15c82572aec74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <algorithm>
#include <bit>
#include <iostream>
#include <vector>

int main() {
	unsigned n, k;
	std::cin >> n >> k;
	std::vector<unsigned> a(n);
	for (unsigned i = 0; i < n; i++) {
		for (unsigned j = 0, p = 1; j < k; j++, p <<= 1) {
			char c;
			std::cin >> c;
			if (c == '1') a[i] += p;
		}
	}
	int s = k+1;
	for (unsigned i = 0; i < n; i++)
		for (unsigned j = i+1; j < n; j++)
			s = std::min(s, std::popcount(a[i] ^ a[j]));
	std::cout << s << "\n";
}

Generated with cgit - Back to sebastiano.tronto.net