fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. vector<int> a = {1, 2, 1, 4, 1, 2, 1};
  6. vector<int> pref_sum(a.size() + 1), pref_xor(a.size() + 1);
  7. partial_sum(a.begin(), a.end(), pref_sum.begin() + 1);
  8. partial_sum(a.begin(), a.end(), pref_xor.begin() + 1, bit_xor<int>());
  9.  
  10. for (auto vec : {pref_sum, pref_xor}) {
  11. for (int x : vec) {
  12. cout << x << " ";
  13. }
  14. cout << "\n";
  15. }
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 4752KB
stdin
Standard input is empty
stdout
0 1 3 4 8 9 11 12 
0 1 3 2 6 7 5 4