mrinal2193's blog

By mrinal2193, history, 5 weeks ago, In English

i didn't get the last part of the code related to finding element in the multiset whose xor with given number results maximum. can someone help me with this pls!! the code is as follows:-

include <bits/stdc++.h>

using namespace std; multiset s; int main() { s.insert(0); int q; cin >> q; while (q--) { char a; int x; cin >> a >> x; if (a=='+') s.insert(x); else if (a=='-') s.erase(s.find(x)); else { int ans=0; for (int j=30;j>=0;j--) { int i=(1<<j); ans|=(&i); auto it=s.lower_bound(ans); if (it==s.end() || *it>=ans+i) ans^=i; } cout << (ans^x) << endl; } } }

 
 
 
 
  • Vote: I like it
  • -26
  • Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by mrinal2193 (previous revision, new revision, compare).

»
5 weeks ago, # |
  Vote: I like it +12 Vote: I do not like it

Put some effort in asking the question, make links for easy access, write English in a correct way, format the code so it is readable and then you may get the answers.