Advertisement
Saleh127

CF 1262B

Oct 14th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. ll n,d,e,i,j,k,l=0;
  14. cin>>n;
  15. ll a[n],c[n];
  16. for(i=1; i<=n; i++)
  17. {
  18. a[i]=i;
  19. }
  20.  
  21. for(i=1; i<=n; i++)
  22. {
  23. cin>>d;
  24. if(d<i)
  25. {
  26. l=1;
  27. }
  28. if(d>i)
  29. {
  30. swap(a[d],a[i]);
  31. }
  32. }
  33. if(l) cout<<-1<<endl;
  34. else
  35. {
  36. for(i=1; i<=n; i++)
  37. {
  38. cout<<a[i]<<" ";
  39. }
  40. cout<<endl;
  41. }
  42. }
  43.  
  44.  
  45. return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement