Advertisement
Guest User

Untitled

a guest
Dec 28th, 2024
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <map>
  5. #include <set>
  6.  
  7. enum {P,W,F,B};
  8. char str[] = "PWFB";
  9. //hun: char str[] = "MBEH";
  10.  
  11. int main()
  12. {
  13.     int max = 4*4*4 * 4*4*4*4 * 7*7;
  14.     std::map<std::string, std::vector<std::string>> m;
  15.     std::map<std::string, std::set<std::string>> fbs;
  16.     for(int i = 0; i<max; i++)
  17.     {
  18.         int n = i;
  19.         int small = n % 7;
  20.         n /= 7;
  21.         int big = n % 7;
  22.         n /= 7;
  23.         int t[7];
  24.         int c[4] = {0, 0, 0, 0};
  25.         int p = -1;
  26.         bool bad = false;
  27.         int f = 0;
  28.         int b = 0;
  29.         for(int j = 0; j<7; j++)
  30.         {
  31.             t[j] = n % 4;
  32.             n/=4;
  33.             c[t[j]]++;
  34.             if(t[j] == F) f = j;
  35.             if(t[j] == B) b = j;
  36.             if(t[j] == W && p != P)
  37.             {
  38.                 bad = true;
  39.                 break;
  40.             }
  41.             p = t[j];
  42.         }
  43.         if(bad) continue;
  44.         if(c[P] != 3 || c[W] != 2 || c[F] != 1 || c[B] != 1) continue;
  45.         if(t[0] == t[6]) continue;
  46.         if(t[0] == F) continue;
  47.         if(t[6] == F) continue;
  48.         if(t[1] != t[5]) continue;
  49.         if(small == big) continue;
  50.         if(t[small] == P) continue;
  51.         if(t[big] == P) continue;
  52.         std::string s;
  53.         for(int j: t) s.push_back(str[j]);
  54.         //std::cout << s << "\n";
  55.         std::string sb = std::to_string(small) + std::to_string(big);
  56.         std::string fb = std::to_string(f) + std::to_string(b);
  57.         /*for(int j = 0; j<7; j++)
  58.         {
  59.             if(j == small) std::cout << "s";
  60.             else if (j == big ) std::cout << "b";
  61.             else std::cout << " ";
  62.         }*/
  63.         m[sb].push_back(s);
  64.         fbs[sb].insert(fb);
  65.         //std::cout << "\n\n";
  66.     }
  67.  
  68.     std::map<std::string, std::vector<std::string>> m2;
  69.     for(auto& [sb, strings]: m)
  70.     {
  71.         int small = sb[0]-'0';
  72.         if(fbs[sb].size() != 1) continue;
  73.         for(auto& s: strings){
  74.             if(s[small] != str[F]) continue;
  75.             if(s[6] != str[B]) continue;
  76.             m2[sb].push_back(s);
  77.         }
  78.     }
  79.  
  80.     for(auto& [sb, strings]: m2)
  81.     {
  82.         int small = sb[0]-'0';
  83.         int big = sb[1]-'0';
  84.         for(int j = 0; j<7; j++)
  85.         {
  86.             if(j == small) std::cout << "s";
  87.             else if (j == big ) std::cout << "B";
  88.             else std::cout << " ";
  89.         }
  90.         std::cout << "\n";
  91.         for(auto& s: strings){
  92.             std::cout << s << "\n";
  93.         }
  94.     }
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement