Advertisement
CotoiRares

Untitled

Jan 22nd, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. vector<pair<int, int>> boxes;
  6.  
  7. int main()
  8. {
  9. int n,t;
  10. cin >> t;
  11. for(int i = 0; i < t; i++)
  12. {
  13. cin >> n;
  14. int c=0,pas=0,ok=0;
  15. boxes.clear();
  16. for(int j = 0; j < n; j++)
  17. {
  18. int x,y;
  19. cin >> x >> y;
  20. boxes.push_back({x, y});
  21. }
  22. sort(boxes.begin(), boxes.end());
  23. int xcutie=boxes[i].first, ycutie=boxes[i].second;
  24. do
  25. {
  26. if (xcutie)
  27. {
  28. xcutie++;
  29. c++;
  30. ok=1;
  31. }
  32. if (ycutie)
  33. {
  34. ycutie++;
  35. c++;
  36. ok=1;
  37. }
  38. pas++;
  39.  
  40. }while (c==n || pas>=n*n);
  41. if (!ok)
  42. {
  43. cout<<"NO"<<endl;
  44. }
  45. else
  46. {
  47. cout<<"YES"<<endl;
  48. xcutie=boxes[i].first;
  49. ycutie=boxes[i].second;
  50. do
  51. {
  52. if (xcutie)
  53. {
  54. xcutie++;
  55. c++;
  56. cout<<"U";
  57. }
  58. if (ycutie)
  59. {
  60. ycutie++;
  61. c++;
  62. cout<<"R";
  63. }
  64. }while (c==n);
  65. }
  66. cout<<endl;
  67. }
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement