Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<int> a(n);
- for(auto &e: a)
- cin>>e;
- set<int> st;
- for(int i=0; i<=n; i++)
- st.insert(i);
- for(auto e: a)
- st.erase(e);
- if(st.size() == 0)
- st.insert(n+1);
- int y;
- while(true)
- {
- cout<<*st.begin()<<endl;
- st.erase(st.begin());
- cin>>y;
- if(y == -1) break;
- st.insert(y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment