#include<bits/stdc++.h>
using namespace std;
int main()
{
long T,n,m,i,arry[120],second,third,temp[120],c=1;
char first;
// freopen("check.txt","r",stdin);
scanf("%ld",&T);
while(T--)
{
scanf("%ld%ld",&n,&m);
for(i=0; i<n; i++)
scanf("%ld",&arry[i]);
while(m--)
{
cin >> first;
if(first == 'S' || first == 'M' || first == 'D')
{
scanf("%ld",&second);
if(first == 'S')
{
for(i=0; i<n; i++)
arry[i] += second;
}
else if(first == 'M')
{
for(i=0; i<n; i++)
arry[i] *= second;
}
else if(first == 'D')
{
for(i=0; i<n; i++)
arry[i] /= second;
}
}
else if(first == 'R')
{
int k=0;
for(i=n-1; i>=0; i--)
temp[k++]=arry[i];
for(i=0; i<n; i++)
arry[i]=temp[i];
}
else if(first == 'P')
{
int t;
scanf("%ld%ld",&second,&third);
t=arry[second];
arry[second]=arry[third];
arry[third]=t;
}
}
printf("Case %ld:\n",c++);
for(i=0; i<n; i++)
{
if(i)
printf(" ");
printf("%ld",arry[i]);
}
printf("\n");
}
return 0;
}
Thursday, July 30, 2015
1133 - Array Simulation
Subscribe to:
Post Comments (Atom)
Triathlon
Triathlon - CodeChef # include < bits/stdc++.h > using namespace std ; # define fi first # define se second # define mp ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , c = 1 ; double r1 , r2 , h , p ; // ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { long long T , S , l , n , c = 1 ; // freopen(&qu...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , n , p , q , c = 1 , i , w , t , arry [ 50 ] ; ...
No comments:
Post a Comment