This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
public class gift {
int construct(int n, int r, int[] a, int[] b, int[] x) {
String s = "";
for(int i=0; i<r; i++) {
if(a[i] == 0) {
for(int j = a[i]; j <= b[i]; j++)
{
if(x[i] == 1) {//red
if(s.length() !=0 && s.length()-1 >= j) {
if(s.charAt(j) == 'B')//
{
return 0;
} else if(s.charAt(j) == 'R'){
s = s;
}
}
s= s + "R";
}
else if(x[i] == 2) // blue
{
if(s.length() !=0 && s.length()-1 >= j) {
if(s.charAt(j) == 'R')
{
return 0;
} else if(s.charAt(j) == 'B'){
s = s;
}
}
s = s + "B";
}
}
}
else
{
for(int j = a[i]+1; j <= b[i]; j++)
{
if(x[i] == 1) {//red
if(s.length() !=0 && s.length()-1 >= j) {
if(s.charAt(j) == 'B')//
{
return 0;
} else if(s.charAt(j) == 'R'){
s = s;
}
}
s= s + "R";
}
else if(x[i] == 2) // blue
{
if(s.length() !=0 && s.length()-1 >= j) {
if(s.charAt(j) == 'R')
{
return 0;
} else if(s.charAt(j) == 'B'){
s = s;
}
}
s = s + "B";
}
}
}
}
grader.craft(s);
return 1;
}
}
# | 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... |