-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLightOj 1133.cpp
121 lines (88 loc) · 1.94 KB
/
LightOj 1133.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*Which of the favors of your Lord will you deny ?*/
#include<bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
#define LL long long
int powa(int x,int n)
{
if(n==0)
return 1;
int u=powa(x,n/2);
u=u*u;
if(n%2==1)
u=u*x;
return u;
}
vector<int>ara;
int main()
{
//freopen("outLOJ1133.txt","w",stdout);
int tc;
scanf("%d",&tc);
for(int t=1; t<=tc; t++)
{
int n,q;
scanf("%d %d",&n,&q);
ara.clear();
for(int i=0; i<n; i++)
{
int v;
scanf("%d",&v);
ara.push_back(v);
}
//scanf("%d",&ara[i]);
for(int i=1; i<=q; i++)
{
//cout<<"npoooooo"<<endl;
char ch;
//getchar();
//fflush(stdin);
scanf(" %c",&ch);
if(ch=='S')
{
int a;
scanf("%d",&a);
for(int j=0; j<n; j++)
{
ara[j]+=a;
}
}
if(ch=='M')
{
int a;
scanf("%d",&a);
for(int j=0; j<n; j++)
{
ara[j]*=a;
}
}
if(ch=='D')
{
int a;
scanf("%d",&a);
for(int j=0; j<n; j++)
{
ara[j]/=a;
}
}
if(ch=='R')
reverse(ara.begin(),ara.end());
if(ch=='P')
{
int a,b;
scanf("%d %d",&a,&b);
swap(ara[a],ara[b]);
}
}
printf("Case %d:\n",t);
for(int ee=0; ee<n; ee++)
{
if(ee==n-1)
printf("%d",ara[ee]);
else
printf("%d ",ara[ee]);
}
printf("\n");
}
return 0;
}