Saleh127

Light oj 1133

Jun 14th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long int a[10000],b,d,e,f,g,h,k,t,q,n,m;
  6. char c;
  7. cin>>t;
  8. for(q=1; q<=t; q++)
  9. {
  10. cin>>n>>m;
  11. for(int i=0; i<n; i++)
  12. {
  13. cin>>a[i];
  14. }
  15. for(int i=0; i<m; i++)
  16. {
  17. cin>>c;
  18. if(c=='S')
  19. {
  20. cin>>d;
  21. for(int i=0; i<n; i++)
  22. {
  23. a[i]+=d;
  24. }
  25. }
  26. else if(c=='M')
  27. {
  28. cin>>d;
  29. for(int i=0; i<n; i++)
  30. {
  31. a[i]*=d;
  32. }
  33. }
  34. else if(c=='D')
  35. {
  36. cin>>d;
  37. for(int i=0; i<n; i++)
  38. {
  39. a[i]/=d;
  40. }
  41. }
  42. else if(c=='R')
  43. {
  44. for(int i=0,j=n-1; i<j; i++,j--)
  45. {
  46. swap(a[i],a[j]);
  47. }
  48. }
  49. else if(c=='P')
  50. {
  51. cin>>e>>f;
  52. swap(a[e],a[f]);
  53. }
  54. }
  55. cout<<"Case "<<q<<":"<<endl;
  56. for(int l=0;l<n-1;l++)
  57. {
  58. cout<<a[l]<<" ";
  59. }
  60. cout<<a[n-1]<<endl;
  61. }
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment