fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. //10
  4. int arr[100001];
  5. int dp[100001];
  6. int main() {
  7. long long n;
  8. cin>>n;
  9. for (int i=0;i<n;i++) {
  10. cin>>arr[i];
  11. dp[i]=i+arr[i];
  12. }
  13. for (int i=0;i<n;i++) {
  14. for (int j=0;j<n;j++) {
  15. dp[i]=dp[dp[j]];
  16. if (dp[i]>n||dp[i]<1) break;
  17. }
  18. if (dp[i]>n) cout<<'R'<<endl;
  19. else if (dp[i]<1) cout<<'L'<<endl;
  20. else cout<<'U'<<endl;
  21.  
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5432KB
stdin
10
-5
2
0
5
5
-1
6
-1
-1
-5
stdout
R
L
L
L
L
L
L
L
L
L