Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1.     /*
  2.     By: facug91
  3.     From: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2217
  4.     Name: Pole Position
  5.     Date: 06/10/2015
  6. */
  7.  
  8. #include <bits/stdc++.h>
  9. #define next    asjkdbg1238dv8ydf38gy832gf8yd
  10. #define prev    jasdjksadjsadho32r80ejd8h3rsd
  11. #define right   nkdbj3dsbuhdfhu32rbhkdfhubj38
  12. #define down    pjasfias3dbasdgsauidb39dgsa92
  13. #define EPS 1e-9
  14. #define MP make_pair
  15. #define DEB(x) cerr << "#" << (#x) << ": " << (x) << endl
  16. const double PI = 2.0*acos(0.0);
  17.  
  18. #define INF 1000000000
  19. //#define MOD 1000000007ll
  20. #define MAXN 500
  21.  
  22. using namespace std;
  23. typedef long long ll;
  24. typedef pair<int, int> ii; typedef pair<int, ii> iii;
  25. typedef vector<int> vi;    typedef vector<ii> vii;      typedef vector<iii> viii;
  26.  
  27. int n, a[1005], b[1005], c[1005];
  28.  
  29. int main () {
  30.     ios_base::sync_with_stdio(0); cin.tie(0);
  31.     //cout<<fixed<<setprecision(7); cerr<<fixed<<setprecision(7); //cin.ignore(INT_MAX, ' '); //cout << setfill('0') << setw(5) << 25
  32.     int i, j;
  33.    
  34.     while (cin>>n, n) {
  35.         for (i=1; i<=n; i++) cin>>a[i]>>b[i];
  36.         memset(c, -1, sizeof c);
  37.         bool ok = true;
  38.         for (i=1; i<=n; i++) {
  39.             int p = i + b[i];
  40.             if (p > 0 && p <= n && c[p] == -1) c[p] = a[i];
  41.             else ok = false;
  42.         }
  43.         if (!ok) cout<<-1<<endl;
  44.         else {
  45.             cout<<c[1];
  46.             for (i=2; i<=n; i++) cout<<" "<<c[i];
  47.             cout<<endl;
  48.         }
  49.     }
  50.    
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement