#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define F first
#define S second
#define sz(x) (ll)x.size()
#define pb push_back
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i= 0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
bool checkWhite(const ll n, const ll k, const ll i, string &s, vi &c){
ll p = -2; //posisition of last black
ll x = 0; //block index
while (x < k && p + 1 + c[x] < i){
p += c[x] + 1;
x++;
}
if (x >= k) return true;
p = i-1;
while (x < k && p + c[x] + 1 < n){
p += c[x] + 1;
x++;
}
return (x >= k);
}
bool checkBlack(const ll n, const ll k, const ll i, string &s, vi &c){
// dbg(i);
ll p = -2; //posisition of last black
ll x = 0; //block index
while (x < k-1 && p + 1 + c[x] < i-1){
p += c[x] + 1;
x++;
}
// dbg(p);
p = max(p + c[x] + 1, i);
x++;
// dbg(p);
while (x < k && p + c[x] + 1 < n){
p += c[x] + 1;
x++;
}
// dbg(x);
// cout<<endl;
return (x >= k);
}
string solve_puzzle(string s, vi c) {
ll n = sz(s);
ll k = sz(c);
string ans;
ans.resize(n);
for (ll i =0; i<n; i++){
bool w = checkWhite(n,k,i,s,c);
bool b = checkBlack(n,k,i,s,c);
if (w && b) ans[i] = '?';
else if (w) ans[i] = '_';
else ans[i] = 'X';
}
return ans;
}
/*
..........
3 1 3 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 13, m = 1 |
2 |
Correct |
1 ms |
348 KB |
n = 18, m = 1 |
3 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
4 |
Correct |
0 ms |
348 KB |
n = 1, m = 1 |
5 |
Correct |
1 ms |
344 KB |
n = 20, m = 1 |
6 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
7 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 13, m = 1 |
2 |
Correct |
1 ms |
348 KB |
n = 18, m = 1 |
3 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
4 |
Correct |
0 ms |
348 KB |
n = 1, m = 1 |
5 |
Correct |
1 ms |
344 KB |
n = 20, m = 1 |
6 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
7 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
8 |
Correct |
0 ms |
348 KB |
n = 20, m = 5 |
9 |
Correct |
0 ms |
348 KB |
n = 18, m = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 17, m = 2 |
11 |
Correct |
0 ms |
348 KB |
n = 20, m = 2 |
12 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
13 |
Correct |
0 ms |
444 KB |
n = 17, m = 6 |
14 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
15 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
16 |
Correct |
0 ms |
348 KB |
n = 13, m = 3 |
17 |
Correct |
0 ms |
348 KB |
n = 18, m = 4 |
18 |
Correct |
0 ms |
348 KB |
n = 20, m = 10 |
19 |
Correct |
1 ms |
344 KB |
n = 19, m = 10 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 13, m = 1 |
2 |
Correct |
1 ms |
348 KB |
n = 18, m = 1 |
3 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
4 |
Correct |
0 ms |
348 KB |
n = 1, m = 1 |
5 |
Correct |
1 ms |
344 KB |
n = 20, m = 1 |
6 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
7 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
8 |
Correct |
0 ms |
348 KB |
n = 20, m = 5 |
9 |
Correct |
0 ms |
348 KB |
n = 18, m = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 17, m = 2 |
11 |
Correct |
0 ms |
348 KB |
n = 20, m = 2 |
12 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
13 |
Correct |
0 ms |
444 KB |
n = 17, m = 6 |
14 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
15 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
16 |
Correct |
0 ms |
348 KB |
n = 13, m = 3 |
17 |
Correct |
0 ms |
348 KB |
n = 18, m = 4 |
18 |
Correct |
0 ms |
348 KB |
n = 20, m = 10 |
19 |
Correct |
1 ms |
344 KB |
n = 19, m = 10 |
20 |
Correct |
1 ms |
348 KB |
n = 100, m = 5 |
21 |
Correct |
0 ms |
348 KB |
n = 90, m = 3 |
22 |
Correct |
0 ms |
348 KB |
n = 86, m = 2 |
23 |
Correct |
0 ms |
348 KB |
n = 81, m = 4 |
24 |
Correct |
0 ms |
348 KB |
n = 89, m = 10 |
25 |
Correct |
1 ms |
344 KB |
n = 81, m = 23 |
26 |
Correct |
1 ms |
348 KB |
n = 86, m = 8 |
27 |
Correct |
0 ms |
348 KB |
n = 53, m = 22 |
28 |
Correct |
0 ms |
348 KB |
n = 89, m = 35 |
29 |
Correct |
0 ms |
348 KB |
n = 63, m = 25 |
30 |
Correct |
0 ms |
348 KB |
n = 100, m = 50 |
31 |
Correct |
0 ms |
348 KB |
n = 99, m = 50 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 13, m = 1 |
2 |
Correct |
1 ms |
348 KB |
n = 18, m = 1 |
3 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
4 |
Correct |
0 ms |
348 KB |
n = 1, m = 1 |
5 |
Correct |
1 ms |
344 KB |
n = 20, m = 1 |
6 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
7 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
8 |
Correct |
0 ms |
348 KB |
n = 20, m = 5 |
9 |
Correct |
0 ms |
348 KB |
n = 18, m = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 17, m = 2 |
11 |
Correct |
0 ms |
348 KB |
n = 20, m = 2 |
12 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
13 |
Correct |
0 ms |
444 KB |
n = 17, m = 6 |
14 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
15 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
16 |
Correct |
0 ms |
348 KB |
n = 13, m = 3 |
17 |
Correct |
0 ms |
348 KB |
n = 18, m = 4 |
18 |
Correct |
0 ms |
348 KB |
n = 20, m = 10 |
19 |
Correct |
1 ms |
344 KB |
n = 19, m = 10 |
20 |
Correct |
1 ms |
348 KB |
n = 100, m = 5 |
21 |
Correct |
0 ms |
348 KB |
n = 90, m = 3 |
22 |
Correct |
0 ms |
348 KB |
n = 86, m = 2 |
23 |
Correct |
0 ms |
348 KB |
n = 81, m = 4 |
24 |
Correct |
0 ms |
348 KB |
n = 89, m = 10 |
25 |
Correct |
1 ms |
344 KB |
n = 81, m = 23 |
26 |
Correct |
1 ms |
348 KB |
n = 86, m = 8 |
27 |
Correct |
0 ms |
348 KB |
n = 53, m = 22 |
28 |
Correct |
0 ms |
348 KB |
n = 89, m = 35 |
29 |
Correct |
0 ms |
348 KB |
n = 63, m = 25 |
30 |
Correct |
0 ms |
348 KB |
n = 100, m = 50 |
31 |
Correct |
0 ms |
348 KB |
n = 99, m = 50 |
32 |
Incorrect |
1 ms |
348 KB |
char #1 differ - expected: 'X', found: '?' |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 13, m = 1 |
2 |
Correct |
1 ms |
348 KB |
n = 18, m = 1 |
3 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
4 |
Correct |
0 ms |
348 KB |
n = 1, m = 1 |
5 |
Correct |
1 ms |
344 KB |
n = 20, m = 1 |
6 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
7 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
8 |
Correct |
0 ms |
348 KB |
n = 20, m = 5 |
9 |
Correct |
0 ms |
348 KB |
n = 18, m = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 17, m = 2 |
11 |
Correct |
0 ms |
348 KB |
n = 20, m = 2 |
12 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
13 |
Correct |
0 ms |
444 KB |
n = 17, m = 6 |
14 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
15 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
16 |
Correct |
0 ms |
348 KB |
n = 13, m = 3 |
17 |
Correct |
0 ms |
348 KB |
n = 18, m = 4 |
18 |
Correct |
0 ms |
348 KB |
n = 20, m = 10 |
19 |
Correct |
1 ms |
344 KB |
n = 19, m = 10 |
20 |
Correct |
1 ms |
348 KB |
n = 100, m = 5 |
21 |
Correct |
0 ms |
348 KB |
n = 90, m = 3 |
22 |
Correct |
0 ms |
348 KB |
n = 86, m = 2 |
23 |
Correct |
0 ms |
348 KB |
n = 81, m = 4 |
24 |
Correct |
0 ms |
348 KB |
n = 89, m = 10 |
25 |
Correct |
1 ms |
344 KB |
n = 81, m = 23 |
26 |
Correct |
1 ms |
348 KB |
n = 86, m = 8 |
27 |
Correct |
0 ms |
348 KB |
n = 53, m = 22 |
28 |
Correct |
0 ms |
348 KB |
n = 89, m = 35 |
29 |
Correct |
0 ms |
348 KB |
n = 63, m = 25 |
30 |
Correct |
0 ms |
348 KB |
n = 100, m = 50 |
31 |
Correct |
0 ms |
348 KB |
n = 99, m = 50 |
32 |
Incorrect |
1 ms |
348 KB |
char #1 differ - expected: 'X', found: '?' |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 13, m = 1 |
2 |
Correct |
1 ms |
348 KB |
n = 18, m = 1 |
3 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
4 |
Correct |
0 ms |
348 KB |
n = 1, m = 1 |
5 |
Correct |
1 ms |
344 KB |
n = 20, m = 1 |
6 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
7 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
8 |
Correct |
0 ms |
348 KB |
n = 20, m = 5 |
9 |
Correct |
0 ms |
348 KB |
n = 18, m = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 17, m = 2 |
11 |
Correct |
0 ms |
348 KB |
n = 20, m = 2 |
12 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
13 |
Correct |
0 ms |
444 KB |
n = 17, m = 6 |
14 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
15 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
16 |
Correct |
0 ms |
348 KB |
n = 13, m = 3 |
17 |
Correct |
0 ms |
348 KB |
n = 18, m = 4 |
18 |
Correct |
0 ms |
348 KB |
n = 20, m = 10 |
19 |
Correct |
1 ms |
344 KB |
n = 19, m = 10 |
20 |
Correct |
1 ms |
348 KB |
n = 100, m = 5 |
21 |
Correct |
0 ms |
348 KB |
n = 90, m = 3 |
22 |
Correct |
0 ms |
348 KB |
n = 86, m = 2 |
23 |
Correct |
0 ms |
348 KB |
n = 81, m = 4 |
24 |
Correct |
0 ms |
348 KB |
n = 89, m = 10 |
25 |
Correct |
1 ms |
344 KB |
n = 81, m = 23 |
26 |
Correct |
1 ms |
348 KB |
n = 86, m = 8 |
27 |
Correct |
0 ms |
348 KB |
n = 53, m = 22 |
28 |
Correct |
0 ms |
348 KB |
n = 89, m = 35 |
29 |
Correct |
0 ms |
348 KB |
n = 63, m = 25 |
30 |
Correct |
0 ms |
348 KB |
n = 100, m = 50 |
31 |
Correct |
0 ms |
348 KB |
n = 99, m = 50 |
32 |
Incorrect |
1 ms |
348 KB |
char #1 differ - expected: 'X', found: '?' |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
n = 13, m = 1 |
2 |
Correct |
1 ms |
348 KB |
n = 18, m = 1 |
3 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
4 |
Correct |
0 ms |
348 KB |
n = 1, m = 1 |
5 |
Correct |
1 ms |
344 KB |
n = 20, m = 1 |
6 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
7 |
Correct |
0 ms |
348 KB |
n = 20, m = 1 |
8 |
Correct |
0 ms |
348 KB |
n = 20, m = 5 |
9 |
Correct |
0 ms |
348 KB |
n = 18, m = 3 |
10 |
Correct |
0 ms |
348 KB |
n = 17, m = 2 |
11 |
Correct |
0 ms |
348 KB |
n = 20, m = 2 |
12 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
13 |
Correct |
0 ms |
444 KB |
n = 17, m = 6 |
14 |
Correct |
0 ms |
348 KB |
n = 17, m = 1 |
15 |
Correct |
0 ms |
348 KB |
n = 17, m = 4 |
16 |
Correct |
0 ms |
348 KB |
n = 13, m = 3 |
17 |
Correct |
0 ms |
348 KB |
n = 18, m = 4 |
18 |
Correct |
0 ms |
348 KB |
n = 20, m = 10 |
19 |
Correct |
1 ms |
344 KB |
n = 19, m = 10 |
20 |
Correct |
1 ms |
348 KB |
n = 100, m = 5 |
21 |
Correct |
0 ms |
348 KB |
n = 90, m = 3 |
22 |
Correct |
0 ms |
348 KB |
n = 86, m = 2 |
23 |
Correct |
0 ms |
348 KB |
n = 81, m = 4 |
24 |
Correct |
0 ms |
348 KB |
n = 89, m = 10 |
25 |
Correct |
1 ms |
344 KB |
n = 81, m = 23 |
26 |
Correct |
1 ms |
348 KB |
n = 86, m = 8 |
27 |
Correct |
0 ms |
348 KB |
n = 53, m = 22 |
28 |
Correct |
0 ms |
348 KB |
n = 89, m = 35 |
29 |
Correct |
0 ms |
348 KB |
n = 63, m = 25 |
30 |
Correct |
0 ms |
348 KB |
n = 100, m = 50 |
31 |
Correct |
0 ms |
348 KB |
n = 99, m = 50 |
32 |
Incorrect |
1 ms |
348 KB |
char #1 differ - expected: 'X', found: '?' |
33 |
Halted |
0 ms |
0 KB |
- |