Advertisement
Korotkodul

N6

Nov 11th, 2022 (edited)
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 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. int f(int a, int b) {
  51.     return 2 * a + b;
  52. }
  53.  
  54. bool sh;
  55.  
  56.  
  57. vector <int> conv(int x) {
  58.     vector <int> r = {-1};
  59.     while (x > 0) {
  60.         r.pb(x % 2);
  61.         x /= 2;
  62.     }
  63.     while (r.size() < 11) {
  64.         r.pb(0);
  65.     }
  66.     return r;
  67. }
  68.  
  69.  
  70. //индексация с 1
  71. vector <int> get(vector <int> x) {
  72.     int a1, a2, a3, a4, a5, b1, b2, b3, b4, b5;
  73.     b1 = f(x[1], x[9]) xor f(x[2], x[10]) xor f(x[3], x[8]) xor f(x[4], x[9]) xor f(x[5], x[9]) xor f(x[6], x[8]) xor f(x[7], x[8]) xor f(x[9], x[10]);
  74.     b2 = f(x[1], x[8]) xor f(x[2], x[9]) xor f(x[3], x[10]) xor f(x[4], x[8]) xor f(x[5], x[10]) xor f(x[6], x[10]) xor f(x[7], x[8]) xor f(x[8], x[9]);
  75.     b3 = f(x[1], x[9]) xor f(x[2], x[10]) xor f(x[3], x[8]) xor f(x[4], x[7]) xor f(x[5], x[8]) xor f(x[6], x[8]) xor f(x[7], x[8]) xor f(x[8], x[9]) xor x[10];
  76.     b4 = f(x[1], x[7]) xor f(x[2], x[10]) xor f(x[3], x[10]) xor f(x[4], x[7]) xor f(x[5], x[7]) xor f(x[6], x[10]) xor f(x[7], x[10]) xor f(x[9], x[10]);
  77.     b5 = f(x[1], x[8]) xor f(x[2], x[7]) xor f(x[3], x[7]) xor f(x[4], x[9]) xor f(x[5], x[9]) xor f(x[6], x[8]) xor f(x[7], x[8]) xor f(x[8], x[10]) xor x[9];
  78.     a1 = b3 xor b4 xor b5;
  79.     a2 = b2 xor b4 xor b5;
  80.     a3 = b2 xor b3 xor b5;
  81.     a4 = b1 xor b2 xor b3;
  82.     a5 = b1 xor b3 xor b5;
  83.     return {a1, a2, a3, a4, a5};
  84. }
  85.  
  86. int main() {
  87.     ios::sync_with_stdio(0);
  88.     cin.tie(0);
  89.     cout.tie(0);
  90.     sh = 1;
  91.     bool is = 0;
  92.     vector <int> to = {0, 1, 0, 0, 0};
  93.     for (int i = 0; i < pow(2, 10); ++i) {
  94.         vector <int> a = conv(i);
  95.         auto v = get(a);
  96.         if (sh) {
  97.             cv(a);
  98.             cv(v);
  99.         }
  100.         if (v == to) {
  101.             cout << "OK\n";
  102.             is = 1;
  103.         }
  104.     }
  105.     if (is) {
  106.         cout << "OK\n";
  107.     } else {
  108.         cout << "NO\n";
  109.     }
  110. }
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement