fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(int tc) {
  5. int n;
  6. cin>>n;
  7. vector<int> b(n),p(n,-1);
  8. for(int &x:b) cin>>x;
  9.  
  10. for(int x=1;x<n+1;x++) {
  11. int i=n+b[x-1]-(x-1);
  12. if(1<=i && i<=n) p[i-1]=x;
  13. }
  14. for(int x:p) {
  15. if(x==-1) {
  16. cout<<-1<<endl;
  17. return;
  18. }
  19. }
  20. for(int i=0;i<n;i++) cout<< p[i] << ' ';
  21. cout << endl;
  22. }
  23.  
  24. int main() {
  25. int t;
  26. cin>>t;
  27. for(int i=0;i<t;i++) solve(i);
  28. }
  29.  
Success #stdin #stdout 0.01s 576KB
stdin
Standard input is empty
stdout