Ankit_132

C

Sep 11th, 2023
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll     long long
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7. #define pb     push_back
  8.  
  9. int main()
  10. {
  11.     _test
  12.     {
  13.         int n;
  14.         cin>>n;
  15.  
  16.         vector<int> a(n);
  17.         for(auto &e: a)
  18.             cin>>e;
  19.  
  20.         set<int> st;
  21.         for(int i=0; i<=n; i++)
  22.             st.insert(i);
  23.  
  24.         for(auto e: a)
  25.             st.erase(e);
  26.  
  27.         if(st.size() == 0)
  28.             st.insert(n+1);
  29.  
  30.         int y;
  31.  
  32.         while(true)
  33.         {
  34.             cout<<*st.begin()<<endl;
  35.             st.erase(st.begin());
  36.  
  37.             cin>>y;
  38.             if(y == -1)     break;
  39.  
  40.             st.insert(y);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment