-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbee2292.cpp
More file actions
46 lines (31 loc) · 771 Bytes
/
Copy pathbee2292.cpp
File metadata and controls
46 lines (31 loc) · 771 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
43
44
45
46
/*
* Contest : Beecrowd
* Problem : 2292 - Painel LED
* Link : https://judge.beecrowd.com/pt/problems/view/2292
*/
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
typedef unsigned long long ull;
char alternar(char c) {
return c == 'X' ? 'O' : 'X';
}
int main() {
fastio
int tc; cin >> tc;
ull c;
string p;
while (tc--) {
cin >> p >> c;
string ans;
ans += c % 2 == 1 ? alternar(p[0]) : p[0];
for (int i = 1; i < p.size(); i++) {
if (ans[i - 1] == 'X')
c++; // se o valor anterior trocou para X, vai ocorrer uma troca a mais
c /= 2; // c = trocas
ans += c % 2 == 1 ? alternar(p[i]) : p[i];
}
printf("%s\n", ans.c_str());
}
return 0;
}