solver solve
  1. #ifndef CONTESTSMTH_HEADER_H
  2. #define CONTESTSMTH_HEADER_H
  3.  
  4. #include <bits/stdc++.h>
  5. #include <ext/pb_ds/assoc_container.hpp>
  6. #include <ext/pb_ds/tree_policy.hpp>
  7. using namespace std;
  8.  
  9. template <typename K, typename V = __gnu_pbds::null_type>
  10. using tree = __gnu_pbds::tree<K, V, less<K>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
  11. template <typename K, typename V = __gnu_pbds::null_type>
  12. using htable = __gnu_pbds::gp_hash_table<K, V>;
  13. using llong = long long;
  14. auto isz = [](const auto& c) { return int(c.size()); };
  15. #ifdef VSE
  16. mt19937 rng(0);
  17. #else
  18. mt19937 rng((size_t) make_shared<char>().get());
  19. #endif
  20.  
  21. #endif //CONTESTSMTH_HEADER_H
  22.  
  23. #ifndef CONTESTSMTH_UTILS_H
  24. #define CONTESTSMTH_UTILS_H
  25.  
  26.  
  27.  
  28. template <typename T, T val = T()>
  29. auto make_vector(size_t d) {
  30.     return vector<T>(d, val);
  31. }
  32.  
  33. template <typename T, T val = T(), typename ...Ds>
  34. auto make_vector(size_t d, Ds... ds) {
  35.     return vector<decltype(make_vector<T, val>(ds...))>(d, make_vector<T, val>(ds...));
  36. }
  37.  
  38. llong min(int a, llong b) {
  39.     return min<llong>(a, b);
  40. }
  41.  
  42. llong min(llong a, int b) {
  43.     return min<llong>(a, b);
  44. }
  45.  
  46. llong max(int a, llong b) {
  47.     return max<llong>(a, b);
  48. }
  49.  
  50. llong max(llong a, int b) {
  51.     return max<llong>(a, b);
  52. }
  53.  
  54. template <typename T>
  55. void relmax(T& a, const T& b) {
  56.     a = max(a, b);
  57. }
  58.  
  59. template <typename T>
  60. void relmin(T& a, const T& b) {
  61.     a = min(a, b);
  62. }
  63.  
  64. #endif //CONTESTSMTH_UTILS_H
  65.  
  66.  
  67. struct Solver {
  68.     void solve() {
  69.         int n;
  70.         cin >> n;
  71.         vector<int> a(n);
  72.         for (int i = 0; i < n; i++) {
  73.             cin >> a[i];
  74.         }
  75.         int prev = 0;
  76.         for (int i = 0; i < n; i++) {
  77.             int y = prev & (~a[i]);
  78.             cout << y << " ";
  79.             prev = a[i] ^ y;
  80.         }
  81.         cout << "n";
  82.     }
  83. };
  84.  
  85. int main(int argc, char** argv) {
  86. #ifdef VSE
  87.     if (argc > 1) assert(freopen(argv[1], "r", stdin));
  88. #endif
  89.     ios_base::sync_with_stdio(false);
  90.     cin.tie(nullptr);
  91.  
  92.     int t = 1;
  93.     cin >> t;
  94.     for (int it = 1; it <= t; it++) {
  95.         Solver().solve();
  96.     }
  97.     return 0;
  98. }
  99.  
  100.  
Parsed in 0.012 seconds