Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- int checked = 0;
- std::vector <int> v[6];
- bool useColors = true;
- int check(int x) {
- int arr[6][4];
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 6; j++) {
- arr[j][i] = v[j][x % checked];
- }
- x /= checked;
- }
- int maxs = -1;
- for (int i = 0; i < 5; i++) {
- for (int j = i + 1; j < 6; j++) {
- int same = 0;
- for (int k = 0; k < 4; k++) {
- if (arr[i][k] == arr[j][k]) same++;
- }
- maxs = std::max(maxs, same);
- }
- }
- return maxs;
- }
- int main() {
- for (int i = 0; i < 6; i++) v[i].resize(15, 2);
- int fst = 0;
- for (int snd = fst + 1; snd < 6; snd++) {
- int trd = (snd == 1) ? 2 : 1;
- for (int fth = 2; fth < 6; fth++) {
- if (fth == trd || fth == snd) continue;
- v[fst][checked] = 0;
- v[snd][checked] = 0;
- v[trd][checked] = 1;
- v[fth][checked] = 1;
- checked++;
- }
- }
- int lim = checked * checked * checked * checked;
- std::pair <int, int> best = {99999, 99999};
- for (int i = 0; i < lim; i++) {
- int res = check(i);
- if (res < best.first) best = {res, i};
- }
- int x = best.second;
- std::cout << "თანაკვეთების მაქსიმალური რაოდენობა: " << best.first << "\n";
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 6; j++) {
- if (useColors == true) std::cout << "\033[4" << v[j][x%checked] + 1 << "m";
- std::cout << v[j][x%checked];
- if (useColors) std::cout << "\033[0m";
- }
- std::cout << "\n";
- x /= checked;
- }
- }
Add Comment
Please, Sign In to add comment