Advertisement
Korotkodul

ИТМО_21-22_N4_OK_30min

Oct 22nd, 2022
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int, int>
  11. #define pb(x) push_back(x)
  12. using namespace std;
  13. using ll = long long;
  14. using ld = long double;
  15. using db = double;
  16. void cv(vector <int> &v) {
  17.     for (auto x : v) cout << x << ' ';
  18.     cout << "\n";
  19. }
  20.  
  21. void cvl(vector <ll> &v) {
  22.     for (auto x : v) cout << x << ' ';
  23.     cout << "\n";
  24. }
  25.  
  26.  
  27. void cvv(vector <vector <int> > &v) {
  28.     for (auto x : v) cv(x);
  29.     cout << "\n";
  30. }
  31.  
  32. void cvb(vector <bool> v) {
  33.     for (bool x : v) cout << x << ' ';
  34.     cout << "\n";
  35. }
  36.  
  37. void cvs(vector <string>  v) {
  38.     for (auto a : v) {
  39.         cout << a << "\n";
  40.     }
  41. }
  42.  
  43. void cvp(vector <pii> a) {
  44.     for (auto p : a) {
  45.         cout << p.first << ' ' << p.second << "\n";
  46.     }
  47.     cout << "\n";
  48. }
  49.  
  50. set < vector <vector <int> > > all;
  51.  
  52. vector <vector <int> > now(9, vector <int> (9, -1));
  53.  
  54. string to(int x) {
  55.     string s = "";
  56.     while (x > 0) {
  57.         s += x % 2 + '0';
  58.         x /= 2;
  59.     }
  60.     reverse(s.begin(), s.end());
  61.     while (s.size() < 17) {
  62.         s = '0' + s;
  63.     }
  64.     return s;
  65. }
  66.  
  67. void gen(string s) {
  68.     vector <vector <int> > one = now;
  69.     int id = -1;
  70.     for (int i = 0; i < 9; ++i) {
  71.         for (int j = 0; j < 9; ++j) {
  72.             if (one[i][j] == -1) {
  73.                 id++;
  74.                 one[i][j] = s[id] - '0';
  75.             }
  76.         }
  77.     }
  78.     all.insert(one);
  79. }
  80.  
  81. //1-bl, 0-wh
  82. int main() {
  83.     ios::sync_with_stdio(0);
  84.     cin.tie(0);
  85.     cout.tie(0);
  86.  
  87.     //left up
  88.     for (int i = 0; i < 8; ++i) {
  89.         for (int j = 0; j < 8; ++j) {
  90.             now[i][j] = 1;
  91.         }
  92.     }
  93.     for (int x = 0; x < pow(2, 17); ++x) {
  94.         string s = to(x);
  95.         gen(s);
  96.     }
  97.  
  98.     //left down
  99.     now.assign(9, vector <int> (9, -1));
  100.     //cvv(now);
  101.     for (int i = 1; i < 9; ++i) {
  102.         for (int j = 0; j < 8; ++j) {
  103.             now[i][j] = 1;
  104.         }
  105.     }
  106.     for (int x = 0; x < pow(2, 17); ++x) {
  107.         string s = to(x);
  108.         gen(s);
  109.     }
  110.  
  111.     //right up
  112.     now.assign(9, vector <int> (9, -1));
  113.     //cvv(now);
  114.     for (int i = 0; i < 8; ++i) {
  115.         for (int j = 1; j < 9; ++j) {
  116.             now[i][j] = 1;
  117.         }
  118.     }
  119.     for (int x = 0; x < pow(2, 17); ++x) {
  120.         string s = to(x);
  121.         gen(s);
  122.     }
  123.  
  124.     //right down
  125.     now.assign(9, vector <int> (9, -1));
  126.     //cvv(now);
  127.     for (int i = 1; i < 9; ++i) {
  128.         for (int j = 1; j < 9; ++j) {
  129.             now[i][j] = 1;
  130.         }
  131.     }
  132.     for (int x = 0; x < pow(2, 17); ++x) {
  133.         string s = to(x);
  134.         gen(s);
  135.     }
  136.     cout << "all size = " << all.size() << "\n";
  137.     int sz = all.size();
  138.     int bit = sz * 81;
  139.     cout << "bit = " << bit;
  140.     int div = pow(2, 20) * 8;
  141.     int ans = (bit + div - 1) / div;
  142.     cout << "ans = " << ans << "\n";
  143. }
  144. /*
  145. all size = 522239
  146. bit = 42301359
  147. ans = 6
  148. */
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement