-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1941D Rudolf and the Ball Game.cpp
61 lines (57 loc) · 1.41 KB
/
1941D Rudolf and the Ball Game.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
/*
author : MishkatIT
created : Wednesday 2024-03-13-00.22.42
*/
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(_) cout << #_ << " is " << _ << '\n';
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 10;
const ll inf = 1e9;
const ll linf = 1e18;
int main()
{
fio;
int t;
cin >> t;
while (t--) {
int n, m, x;
cin >> n >> m >> x;
set<int> pos;
pos.insert(x);
for (int i = 0; i < m; i++) {
int dist;
char dir;
cin >> dist >> dir;
set<int> temp;
if (dir == '?' || dir == '0') {
for (auto& i : pos) {
int x = i + dist;
if (x > n) {
x -= n;
}
temp.insert(x);
}
}
if(dir == '?' || dir == '1') {
for (auto& i : pos) {
int x = i - dist;
if (x <= 0) {
x += n;
}
temp.insert(x);
}
}
pos = temp;
}
cout << pos.size() << '\n';
for (auto& i : pos) {
cout << i << ' ';
}
cout << '\n';
}
return 0;
}