-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1932C.cpp
More file actions
42 lines (39 loc) · 1005 Bytes
/
Copy path1932C.cpp
File metadata and controls
42 lines (39 loc) · 1005 Bytes
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
// Created on 18-Feb-24
//RE. will prolly get tle for nested loop. solve with diff techqn
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector<int> arr(n);
string s;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
cin >> s;
int length = n;
for (int i = 0; i < n; i++) {
int modulo = 1;
for (int j = 0; j < length; j++) {
modulo *= arr[j];
if (j == length - 1)
cout << modulo % m << ' ';
}
if (s[i] == 'L') {
arr.erase(arr.begin());
arr.shrink_to_fit();
length--;
} else if (s[i] == 'R') {
arr.erase(arr.end());
arr.shrink_to_fit();
length--;
}
}
cout << endl;
}
return 0;
}