#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
const char d[] = {'R', 'G', 'B'};
pair<string, int> anna(int N, string S) {
int n = N;
string s = S;
string t(n, '0');
if (n <= 130) {
for (int i = 0; i < n; ++i) {
for (char c : d) {
if (c != s[i]) {
t[i] = c;
break;
}
}
}
return {t, n};
}
map<char, int> mp;
for (char c : s) {
mp[c]++;
}
vector<char> candidates;
for (char c : d) {
if (c != s[129]) {
candidates.push_back(c);
}
}
int chosen = 0;
if (mp[candidates[1]] > n / 2) {
chosen = 1;
}
//now the unchosen appears atmost n / 2 times.
vector<char> unchosen;
for (char c : d) {
if (c != candidates[chosen]) {
unchosen.push_back(c);
//cerr << "C: " << c << endl;
}
}
assert(unchosen.size() == 2 && candidates.size() == 2);
t[129] = candidates[chosen];
for (int i = 0, last = 0; i < n; ++i) {
if (i == 129) {
//if (t[i] == '0') {
//cerr << "I: " << i << endl;
//}
continue;
}
if (s[i] != unchosen[last ^ 1]) {
t[i] = unchosen[last ^ 1];
last ^= 1;
} else {
t[i] = unchosen[last];
}
}
cerr << "T: " << t << endl;
return {t, 130};
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
int n, l;
void init(int N, int l_) {
n = N, l = l_;
}
int bruno(string u) {
if (n <= 130) {
return 1;
}
map<char, int> mp;
for (char c : u) {
mp[c]++;
}
int ind = -1;
for (int i = 0; i < l; ++i) {
if (mp[u[i]] == 1) {
assert(ind == -1);
ind = i;
}
}
return 1 + (129 - ind);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1368 KB |
Output is correct |
2 |
Correct |
23 ms |
1328 KB |
Output is correct |
3 |
Correct |
41 ms |
1324 KB |
Output is correct |
4 |
Correct |
29 ms |
1324 KB |
Output is correct |
5 |
Correct |
30 ms |
1392 KB |
Output is correct |
6 |
Correct |
30 ms |
1336 KB |
Output is correct |
7 |
Correct |
37 ms |
1316 KB |
Output is correct |
8 |
Correct |
56 ms |
1312 KB |
Output is correct |
9 |
Correct |
30 ms |
1320 KB |
Output is correct |
10 |
Correct |
26 ms |
1368 KB |
Output is correct |
11 |
Correct |
25 ms |
1364 KB |
Output is correct |
12 |
Correct |
24 ms |
1384 KB |
Output is correct |
13 |
Correct |
42 ms |
1332 KB |
Output is correct |
14 |
Correct |
42 ms |
1312 KB |
Output is correct |
15 |
Correct |
27 ms |
1360 KB |
Output is correct |
16 |
Correct |
41 ms |
1368 KB |
Output is correct |
17 |
Correct |
24 ms |
1288 KB |
Output is correct |
18 |
Correct |
31 ms |
1328 KB |
Output is correct |
19 |
Correct |
26 ms |
1204 KB |
Output is correct |
20 |
Correct |
27 ms |
1332 KB |
Output is correct |
21 |
Correct |
32 ms |
1324 KB |
Output is correct |
22 |
Correct |
51 ms |
1344 KB |
Output is correct |
23 |
Correct |
26 ms |
1352 KB |
Output is correct |
24 |
Correct |
52 ms |
1320 KB |
Output is correct |
25 |
Correct |
44 ms |
1328 KB |
Output is correct |
26 |
Correct |
26 ms |
1332 KB |
Output is correct |
27 |
Correct |
26 ms |
1296 KB |
Output is correct |
28 |
Correct |
26 ms |
1304 KB |
Output is correct |
29 |
Correct |
55 ms |
1316 KB |
Output is correct |
30 |
Correct |
29 ms |
1392 KB |
Output is correct |
31 |
Correct |
28 ms |
1312 KB |
Output is correct |
32 |
Correct |
36 ms |
1288 KB |
Output is correct |
33 |
Correct |
37 ms |
1288 KB |
Output is correct |
34 |
Correct |
24 ms |
1316 KB |
Output is correct |
35 |
Correct |
25 ms |
1292 KB |
Output is correct |
36 |
Correct |
27 ms |
1328 KB |
Output is correct |
37 |
Correct |
58 ms |
1312 KB |
Output is correct |
38 |
Correct |
46 ms |
1328 KB |
Output is correct |
39 |
Correct |
61 ms |
1316 KB |
Output is correct |
40 |
Correct |
44 ms |
1288 KB |
Output is correct |
41 |
Correct |
43 ms |
1300 KB |
Output is correct |
42 |
Correct |
39 ms |
1316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1368 KB |
Output is correct |
2 |
Correct |
23 ms |
1328 KB |
Output is correct |
3 |
Correct |
41 ms |
1324 KB |
Output is correct |
4 |
Correct |
29 ms |
1324 KB |
Output is correct |
5 |
Correct |
30 ms |
1392 KB |
Output is correct |
6 |
Correct |
30 ms |
1336 KB |
Output is correct |
7 |
Correct |
37 ms |
1316 KB |
Output is correct |
8 |
Correct |
56 ms |
1312 KB |
Output is correct |
9 |
Correct |
30 ms |
1320 KB |
Output is correct |
10 |
Correct |
26 ms |
1368 KB |
Output is correct |
11 |
Correct |
25 ms |
1364 KB |
Output is correct |
12 |
Correct |
24 ms |
1384 KB |
Output is correct |
13 |
Correct |
42 ms |
1332 KB |
Output is correct |
14 |
Correct |
42 ms |
1312 KB |
Output is correct |
15 |
Correct |
27 ms |
1360 KB |
Output is correct |
16 |
Correct |
41 ms |
1368 KB |
Output is correct |
17 |
Correct |
24 ms |
1288 KB |
Output is correct |
18 |
Correct |
31 ms |
1328 KB |
Output is correct |
19 |
Correct |
26 ms |
1204 KB |
Output is correct |
20 |
Correct |
27 ms |
1332 KB |
Output is correct |
21 |
Correct |
32 ms |
1324 KB |
Output is correct |
22 |
Correct |
51 ms |
1344 KB |
Output is correct |
23 |
Correct |
26 ms |
1352 KB |
Output is correct |
24 |
Correct |
52 ms |
1320 KB |
Output is correct |
25 |
Correct |
44 ms |
1328 KB |
Output is correct |
26 |
Correct |
26 ms |
1332 KB |
Output is correct |
27 |
Correct |
26 ms |
1296 KB |
Output is correct |
28 |
Correct |
26 ms |
1304 KB |
Output is correct |
29 |
Correct |
55 ms |
1316 KB |
Output is correct |
30 |
Correct |
29 ms |
1392 KB |
Output is correct |
31 |
Correct |
28 ms |
1312 KB |
Output is correct |
32 |
Correct |
36 ms |
1288 KB |
Output is correct |
33 |
Correct |
37 ms |
1288 KB |
Output is correct |
34 |
Correct |
24 ms |
1316 KB |
Output is correct |
35 |
Correct |
25 ms |
1292 KB |
Output is correct |
36 |
Correct |
27 ms |
1328 KB |
Output is correct |
37 |
Correct |
58 ms |
1312 KB |
Output is correct |
38 |
Correct |
46 ms |
1328 KB |
Output is correct |
39 |
Correct |
61 ms |
1316 KB |
Output is correct |
40 |
Correct |
44 ms |
1288 KB |
Output is correct |
41 |
Correct |
43 ms |
1300 KB |
Output is correct |
42 |
Correct |
39 ms |
1316 KB |
Output is correct |
43 |
Correct |
39 ms |
1320 KB |
Output is correct |
44 |
Correct |
58 ms |
1316 KB |
Output is correct |
45 |
Correct |
41 ms |
1392 KB |
Output is correct |
46 |
Correct |
46 ms |
1320 KB |
Output is correct |
47 |
Correct |
42 ms |
1224 KB |
Output is correct |
48 |
Correct |
63 ms |
1304 KB |
Output is correct |
49 |
Correct |
39 ms |
1320 KB |
Output is correct |
50 |
Correct |
62 ms |
1308 KB |
Output is correct |
51 |
Correct |
41 ms |
1340 KB |
Output is correct |
52 |
Correct |
40 ms |
1348 KB |
Output is correct |
53 |
Correct |
40 ms |
1380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1368 KB |
Output is correct |
2 |
Correct |
23 ms |
1328 KB |
Output is correct |
3 |
Correct |
41 ms |
1324 KB |
Output is correct |
4 |
Correct |
29 ms |
1324 KB |
Output is correct |
5 |
Correct |
30 ms |
1392 KB |
Output is correct |
6 |
Correct |
30 ms |
1336 KB |
Output is correct |
7 |
Correct |
37 ms |
1316 KB |
Output is correct |
8 |
Correct |
56 ms |
1312 KB |
Output is correct |
9 |
Correct |
30 ms |
1320 KB |
Output is correct |
10 |
Correct |
26 ms |
1368 KB |
Output is correct |
11 |
Correct |
25 ms |
1364 KB |
Output is correct |
12 |
Correct |
24 ms |
1384 KB |
Output is correct |
13 |
Correct |
42 ms |
1332 KB |
Output is correct |
14 |
Correct |
42 ms |
1312 KB |
Output is correct |
15 |
Correct |
27 ms |
1360 KB |
Output is correct |
16 |
Correct |
41 ms |
1368 KB |
Output is correct |
17 |
Correct |
24 ms |
1288 KB |
Output is correct |
18 |
Correct |
31 ms |
1328 KB |
Output is correct |
19 |
Correct |
26 ms |
1204 KB |
Output is correct |
20 |
Correct |
27 ms |
1332 KB |
Output is correct |
21 |
Correct |
32 ms |
1324 KB |
Output is correct |
22 |
Correct |
51 ms |
1344 KB |
Output is correct |
23 |
Correct |
26 ms |
1352 KB |
Output is correct |
24 |
Correct |
52 ms |
1320 KB |
Output is correct |
25 |
Correct |
44 ms |
1328 KB |
Output is correct |
26 |
Correct |
26 ms |
1332 KB |
Output is correct |
27 |
Correct |
26 ms |
1296 KB |
Output is correct |
28 |
Correct |
26 ms |
1304 KB |
Output is correct |
29 |
Correct |
55 ms |
1316 KB |
Output is correct |
30 |
Correct |
29 ms |
1392 KB |
Output is correct |
31 |
Correct |
28 ms |
1312 KB |
Output is correct |
32 |
Correct |
36 ms |
1288 KB |
Output is correct |
33 |
Correct |
37 ms |
1288 KB |
Output is correct |
34 |
Correct |
24 ms |
1316 KB |
Output is correct |
35 |
Correct |
25 ms |
1292 KB |
Output is correct |
36 |
Correct |
27 ms |
1328 KB |
Output is correct |
37 |
Correct |
58 ms |
1312 KB |
Output is correct |
38 |
Correct |
46 ms |
1328 KB |
Output is correct |
39 |
Correct |
61 ms |
1316 KB |
Output is correct |
40 |
Correct |
44 ms |
1288 KB |
Output is correct |
41 |
Correct |
43 ms |
1300 KB |
Output is correct |
42 |
Correct |
39 ms |
1316 KB |
Output is correct |
43 |
Correct |
39 ms |
1320 KB |
Output is correct |
44 |
Correct |
58 ms |
1316 KB |
Output is correct |
45 |
Correct |
41 ms |
1392 KB |
Output is correct |
46 |
Correct |
46 ms |
1320 KB |
Output is correct |
47 |
Correct |
42 ms |
1224 KB |
Output is correct |
48 |
Correct |
63 ms |
1304 KB |
Output is correct |
49 |
Correct |
39 ms |
1320 KB |
Output is correct |
50 |
Correct |
62 ms |
1308 KB |
Output is correct |
51 |
Correct |
41 ms |
1340 KB |
Output is correct |
52 |
Correct |
40 ms |
1348 KB |
Output is correct |
53 |
Correct |
40 ms |
1380 KB |
Output is correct |
54 |
Incorrect |
39 ms |
1320 KB |
Wrong Answer [5] |
55 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1368 KB |
Output is correct |
2 |
Correct |
23 ms |
1328 KB |
Output is correct |
3 |
Correct |
41 ms |
1324 KB |
Output is correct |
4 |
Correct |
29 ms |
1324 KB |
Output is correct |
5 |
Correct |
30 ms |
1392 KB |
Output is correct |
6 |
Correct |
30 ms |
1336 KB |
Output is correct |
7 |
Correct |
37 ms |
1316 KB |
Output is correct |
8 |
Correct |
56 ms |
1312 KB |
Output is correct |
9 |
Correct |
30 ms |
1320 KB |
Output is correct |
10 |
Correct |
26 ms |
1368 KB |
Output is correct |
11 |
Correct |
25 ms |
1364 KB |
Output is correct |
12 |
Correct |
24 ms |
1384 KB |
Output is correct |
13 |
Correct |
42 ms |
1332 KB |
Output is correct |
14 |
Correct |
42 ms |
1312 KB |
Output is correct |
15 |
Correct |
27 ms |
1360 KB |
Output is correct |
16 |
Correct |
41 ms |
1368 KB |
Output is correct |
17 |
Correct |
24 ms |
1288 KB |
Output is correct |
18 |
Correct |
31 ms |
1328 KB |
Output is correct |
19 |
Correct |
26 ms |
1204 KB |
Output is correct |
20 |
Correct |
27 ms |
1332 KB |
Output is correct |
21 |
Correct |
32 ms |
1324 KB |
Output is correct |
22 |
Correct |
51 ms |
1344 KB |
Output is correct |
23 |
Correct |
26 ms |
1352 KB |
Output is correct |
24 |
Correct |
52 ms |
1320 KB |
Output is correct |
25 |
Correct |
44 ms |
1328 KB |
Output is correct |
26 |
Correct |
26 ms |
1332 KB |
Output is correct |
27 |
Correct |
26 ms |
1296 KB |
Output is correct |
28 |
Correct |
26 ms |
1304 KB |
Output is correct |
29 |
Correct |
55 ms |
1316 KB |
Output is correct |
30 |
Correct |
29 ms |
1392 KB |
Output is correct |
31 |
Correct |
28 ms |
1312 KB |
Output is correct |
32 |
Correct |
36 ms |
1288 KB |
Output is correct |
33 |
Correct |
37 ms |
1288 KB |
Output is correct |
34 |
Correct |
24 ms |
1316 KB |
Output is correct |
35 |
Correct |
25 ms |
1292 KB |
Output is correct |
36 |
Correct |
27 ms |
1328 KB |
Output is correct |
37 |
Correct |
58 ms |
1312 KB |
Output is correct |
38 |
Correct |
46 ms |
1328 KB |
Output is correct |
39 |
Correct |
61 ms |
1316 KB |
Output is correct |
40 |
Correct |
44 ms |
1288 KB |
Output is correct |
41 |
Correct |
43 ms |
1300 KB |
Output is correct |
42 |
Correct |
39 ms |
1316 KB |
Output is correct |
43 |
Correct |
39 ms |
1320 KB |
Output is correct |
44 |
Correct |
58 ms |
1316 KB |
Output is correct |
45 |
Correct |
41 ms |
1392 KB |
Output is correct |
46 |
Correct |
46 ms |
1320 KB |
Output is correct |
47 |
Correct |
42 ms |
1224 KB |
Output is correct |
48 |
Correct |
63 ms |
1304 KB |
Output is correct |
49 |
Correct |
39 ms |
1320 KB |
Output is correct |
50 |
Correct |
62 ms |
1308 KB |
Output is correct |
51 |
Correct |
41 ms |
1340 KB |
Output is correct |
52 |
Correct |
40 ms |
1348 KB |
Output is correct |
53 |
Correct |
40 ms |
1380 KB |
Output is correct |
54 |
Incorrect |
39 ms |
1320 KB |
Wrong Answer [5] |
55 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1328 KB |
Output is correct |
2 |
Correct |
24 ms |
1400 KB |
Output is correct |
3 |
Correct |
46 ms |
1344 KB |
Output is correct |
4 |
Correct |
43 ms |
1376 KB |
Output is correct |
5 |
Partially correct |
46 ms |
1308 KB |
Partially correct |
6 |
Partially correct |
31 ms |
1328 KB |
Partially correct |
7 |
Partially correct |
41 ms |
1324 KB |
Partially correct |
8 |
Partially correct |
36 ms |
1360 KB |
Partially correct |
9 |
Partially correct |
44 ms |
1320 KB |
Partially correct |
10 |
Partially correct |
55 ms |
1308 KB |
Partially correct |
11 |
Incorrect |
38 ms |
1316 KB |
Wrong Answer [5] |
12 |
Halted |
0 ms |
0 KB |
- |