Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
- typedef long long ll;
- int main()
- {
- fast();
- ll t;
- cin>>t;
- for(ll i=1;i<=t;i++)
- {
- ll n,q,k;
- cin>>n>>q;
- ll ara[n+1];
- char x;
- for(ll j=0;j<n;j++)cin>>ara[j];
- while(q--)
- {
- cin>>x;
- if(x=='S')
- {
- cin>>k;
- for(ll j=0;j<n;j++)ara[j]+=k;
- }
- else if(x=='M')
- {
- cin>>k;
- for(ll j=0;j<n;j++)ara[j]*=k;
- }
- else if(x=='D')
- {
- cin>>k;
- for(ll j=0;j<n;j++)ara[j]/=k;
- }
- else if(x=='P')
- {
- cin>>k;
- ll w;
- cin>>w;
- ll z;
- z=ara[k];
- ara[k]=ara[w];
- ara[w]=z;
- }
- else
- {
- reverse(ara,ara+n);
- }
- }
- cout<< "Case "<<i<<":"<<endl;
- for(ll j=0;j<n-1;j++)cout<<ara[j]<< " ";
- cout<<ara[n-1]<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement