Advertisement
Korotkodul

ITMO_15-16_excel_N1

Nov 22nd, 2022 (edited)
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.90 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.  
  51. int cnv(char x) {
  52.     return x - 'A';
  53. }
  54.  
  55. string to(int x) {
  56.     string r;
  57.     while (x < 0) {
  58.         r += x % 2 + '0';
  59.         x /= 2;
  60.     }
  61.     while (r.size() < 8) {
  62.         r += '0' ;
  63.     }
  64.     return r;
  65. }
  66.  
  67. vector <vector <int> > m, tom;
  68.  
  69. void bld(int a, int b) {
  70.     string as = to(a), bs = to(b);
  71.     m.assign(100, vector <int> (100, 0));
  72.     int cnt = -1;
  73.     for (int i = 3; i <= 10; ++i) {
  74.         cnt++;
  75.         m[i][cnv('B')] = as[cnt] - '0';
  76.     }
  77.     for (int j = cnv('D'); j <= cnv('J'); ++j) {
  78.         m[2][j] = bs[cnt] - '0';
  79.     }
  80.     for (int j = cnv('C'); j <= cnv('J'); ++j) {
  81.         for (int i = 3; i <= 10; ++i) {
  82.             if (m[i - 1][cnv('C')] == 1 && m[2][cnv('D')] == 0 || m[i][cnv('B')] == 0 && m[4][j - 1] == 1) {
  83.                 m[i][j] = 1;
  84.             }
  85.             else {
  86.                 m[i][j] = 0;
  87.             }
  88.         }
  89.     }
  90.     if (m == tom) {
  91.         cout << "OK\n";
  92.         cout << a << ' ' << b << "\n";
  93.         exit(0);
  94.     }
  95. }
  96.  
  97. int main() {
  98.     ios::sync_with_stdio(0);
  99.     cin.tie(0);
  100.     cout.tie(0);
  101.  
  102.     tom.assign(100, vector <int> (100, 0));
  103.     vector <vector <int> > get = {
  104.         {
  105.             1, 0, 0, 1, 1, 1, 0, 1
  106.         },
  107.         {
  108.             1, 1, 1, 1, 1, 1, 1, 1
  109.         },
  110.         {
  111.             1, 0, 0, 1, 1, 1, 0, 1
  112.         },
  113.         {
  114.             1, 0, 0, 1, 1, 1, 0, 1
  115.         },
  116.         {
  117.             1, 0, 0, 1, 1, 1, 0, 1
  118.         },
  119.         {
  120.             1, 1, 1, 1, 1, 1, 1, 1
  121.         },
  122.         {
  123.             1, 0, 0, 1, 1, 1, 0, 1
  124.         },
  125.         {
  126.             1, 1, 1, 1, 1, 1, 1, 1
  127.         }
  128.     };
  129.     int cnti = -1, cntj = -1;
  130.     for (int i = 3; i <= 10; ++i) {
  131.         cnti++;
  132.         cntj = -1;
  133.         for (int j = cnv('C'); j <= cnv('J'); ++j) {
  134.             cntj++;
  135.             tom[i][j] = get[cnti][cntj];
  136.         }
  137.     }
  138.     for (int a = 1; a <= 255; ++a) {
  139.         for (int b = 1; b <= 255; ++b) {
  140.             bld(a, b);
  141.         }
  142.     }
  143.     cout << "WA\n";
  144. }
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement