Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, a, m, x;
  4. bool dziala;
  5. bitset <201> s;
  6. vector<int> v;
  7. int main()
  8. {
  9.     cin >> n;
  10.     for (int j = 1; j <= n; j++)
  11.     {
  12.         s.reset();
  13.         v.clear();
  14.         dziala = 0;
  15.         cin >> m;
  16.         for (int i = 1; i <= m; i++)
  17.         {
  18.             cin >> a;
  19.             s[a] = true;
  20.             v.push_back(a);
  21.             x = a + 1;
  22.             while (x < m * 2)
  23.             {
  24.                 if (s[x] == 1)
  25.                     x++;
  26.                 else
  27.                 {
  28.                     s[x] = true;
  29.                     v.push_back(x);
  30.                     break;
  31.                 }
  32.             }
  33.             if (x > m * 2)
  34.             {
  35.                 cout << -1;
  36.                 dziala = 1;
  37.                 break;
  38.             }
  39.  
  40.         }
  41.         if (dziala == 0)
  42.         {
  43.             for (int i = 0; i < v.size(); i++)
  44.                 cout << v[i] << " ";
  45.         }
  46.         cout << endl;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement