This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int variable_example = 0;
}
pair<string, int> anna(int N, string S) {
string res;
if(N<=130){
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};
}
for(int i=0;i<N;i++)res.insert(res.end(),'$');
{
vector<bool> present(3);
if(S[125]=='R')present[0]=true;
else if(S[125]=='G')present[1]=true;
else if(S[125]=='B')present[2]=true;
if(S[126]=='R')present[0]=true;
else if(S[126]=='G')present[1]=true;
else if(S[126]=='B')present[2]=true;
if(!present[0])res[125]=res[126]='R';
else if(!present[1])res[125]=res[126]='G';
else if(!present[2])res[125]=res[126]='B';
}
for(int i=124;i>=0;i--){
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(res[i+1]=='R')present[0]=true;
else if(res[i+1]=='G')present[1]=true;
else if(res[i+1]=='B')present[2]=true;
if(!present[0])res[i]='R';
else if(!present[1])res[i]='G';
else if(!present[2])res[i]='B';
}
for(int i=127;i<N;i++){
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(res[i-1]=='R')present[0]=true;
else if(res[i-1]=='G')present[1]=true;
else if(res[i-1]=='B')present[2]=true;
if(!present[0])res[i]='R';
else if(!present[1])res[i]='G';
else if(!present[2])res[i]='B';
}
return {res,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;
}
Compilation message (stderr)
Anna.cpp:7:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
7 | int variable_example = 0;
| ^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |