fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. char s[11];
  5.  
  6. int cmp(char *a, char *b) {
  7. int x = 0, y = 0;
  8. for (int i=0; i<5; ++i) {
  9. if (a[i] == b[i]) { ++x; continue; }
  10. for (int j=0; j<5; ++j) if (a[i] == b[j]) { ++y; break; }
  11. }
  12. return 10 * x + y;
  13. }
  14.  
  15.  
  16. char match[8];
  17.  
  18. int main() {
  19. sprintf(s, "0123456789");
  20. map<string, set<string> > m;
  21. do {
  22. reverse(s+5, s+10);
  23.  
  24. int cnt = 0;
  25. match[0] = (cmp(s, "76060") == 2 ? '1' : '0'); if (match[0] == '1') ++cnt;
  26. match[1] = (cmp(s, "24112") == 10 ? '1' : '0'); if (match[1] == '1') ++cnt;
  27. match[2] = (cmp(s, "93535") == 11 ? '1' : '0'); if (match[2] == '1') ++cnt;
  28. match[3] = (cmp(s, "67253") == 2 ? '1' : '0'); if (match[3] == '1') ++cnt;
  29. match[4] = (cmp(s, "01497") == 12 ? '1' : '0'); if (match[4] == '1') ++cnt;
  30. match[5] = (cmp(s, "94501") == 12 ? '1' : '0'); if (match[5] == '1') ++cnt;
  31. match[6] = (cmp(s, "25349") == 3 ? '1' : '0'); if (match[6] == '1') ++cnt;
  32.  
  33. m[string(match)].insert(string(s, s+5));
  34. m[string(match)].insert("04936");
  35.  
  36. } while (next_permutation(s, s+10));
  37.  
  38. for (auto it = m.begin(); it != m.end(); ++it) if (it->second.size() == 1)
  39. printf("%s: %s\n", it->second.begin()->c_str(), it->first.c_str());
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 18120KB
stdin
Standard input is empty
stdout
04936: 1111111