#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
string calc(vector<int> arr,string S){
int N = arr.size()+1;
string res(N,'$');
for(int i=0;i<N-1;i++){
if(arr[i])continue;
vector<bool> present(3);
if(S[i]=='R')present[0]=true;
else if(S[i]=='G')present[1]=true;
else if(S[i]=='B')present[2]=true;
if(S[i+1]=='R')present[0]=true;
else if(S[i+1]=='G')present[1]=true;
else if(S[i+1]=='B')present[2]=true;
if(!present[0])res[i]=res[i+1]='R';
else if(!present[1])res[i]=res[i+1]='G';
else if(!present[2])res[i]=res[i+1]='B';
for(int j=i-1;j>=0;j--){
if(arr[j]!=1)break;
vector<bool> present(3);
if(S[j]=='R')present[0]=true;
else if(S[j]=='G')present[1]=true;
else if(S[j]=='B')present[2]=true;
if(res[j+1]=='R')present[0]=true;
else if(res[j+1]=='G')present[1]=true;
else if(res[j+1]=='B')present[2]=true;
if(!present[0])res[j]='R';
else if(!present[1])res[j]='G';
else if(!present[2])res[j]='B';
}
for(int j=i+1;j<N;j++){
if(arr[j-1]!=1)break;
vector<bool> present(3);
if(S[j]=='R')present[0]=true;
else if(S[j]=='G')present[1]=true;
else if(S[j]=='B')present[2]=true;
if(res[j-1]=='R')present[0]=true;
else if(res[j-1]=='G')present[1]=true;
else if(res[j-1]=='B')present[2]=true;
if(!present[0])res[j]='R';
else if(!present[1])res[j]='G';
else if(!present[2])res[j]='B';
}
}
for(int i=0;i<N;i++)assert(res[i]!='$');
return res;
}
}
pair<string, int> anna(int N, string S) {
if(N<=130){
string res;
for(int i=0;i<N;i++){
if(S[i]=='R')res.insert(res.end(),'B');
else if(S[i]=='B')res.insert(res.end(),'G');
else if(S[i]=='G')res.insert(res.end(),'R');
}
return {res,N};
}
vector<int> res(N-1,1);
res[125]=0;
return {calc(res,S),130};
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int N;
int l;
} // namespace
void init(int N, int l) {
::N = N;
::l = l;
}
int bruno(string u) {
if(N<=130)return 1;
int idxatsame = -1;
for(int i=1;i<l;i++)if(u[i]==u[i-1])idxatsame=i-1;
assert(idxatsame!=-1);
return 126-idxatsame;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1372 KB |
Output is correct |
2 |
Correct |
38 ms |
1316 KB |
Output is correct |
3 |
Correct |
23 ms |
1332 KB |
Output is correct |
4 |
Correct |
31 ms |
1316 KB |
Output is correct |
5 |
Correct |
44 ms |
1332 KB |
Output is correct |
6 |
Correct |
32 ms |
1332 KB |
Output is correct |
7 |
Runtime error |
1 ms |
1368 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1372 KB |
Output is correct |
2 |
Correct |
38 ms |
1316 KB |
Output is correct |
3 |
Correct |
23 ms |
1332 KB |
Output is correct |
4 |
Correct |
31 ms |
1316 KB |
Output is correct |
5 |
Correct |
44 ms |
1332 KB |
Output is correct |
6 |
Correct |
32 ms |
1332 KB |
Output is correct |
7 |
Runtime error |
1 ms |
1368 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1372 KB |
Output is correct |
2 |
Correct |
38 ms |
1316 KB |
Output is correct |
3 |
Correct |
23 ms |
1332 KB |
Output is correct |
4 |
Correct |
31 ms |
1316 KB |
Output is correct |
5 |
Correct |
44 ms |
1332 KB |
Output is correct |
6 |
Correct |
32 ms |
1332 KB |
Output is correct |
7 |
Runtime error |
1 ms |
1368 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1372 KB |
Output is correct |
2 |
Correct |
38 ms |
1316 KB |
Output is correct |
3 |
Correct |
23 ms |
1332 KB |
Output is correct |
4 |
Correct |
31 ms |
1316 KB |
Output is correct |
5 |
Correct |
44 ms |
1332 KB |
Output is correct |
6 |
Correct |
32 ms |
1332 KB |
Output is correct |
7 |
Runtime error |
1 ms |
1368 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
1344 KB |
Output is correct |
2 |
Correct |
25 ms |
1316 KB |
Output is correct |
3 |
Correct |
23 ms |
1344 KB |
Output is correct |
4 |
Correct |
44 ms |
1312 KB |
Output is correct |
5 |
Partially correct |
28 ms |
1360 KB |
Partially correct |
6 |
Partially correct |
30 ms |
1344 KB |
Partially correct |
7 |
Runtime error |
1 ms |
1368 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |