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 "gift.h"
#include <bits/stdc++.h>
using namespace std;
int N, R; vector<int>aa, bb, xx; bool used=false;
void solve(int i, string s)
{
if(used) return;
if(i==N) {
bool found=true;
for(int l=0;l<R&&found;l++) {
int lo=aa[l], hi=bb[l], v=xx[l];
if(v==1) {
int r=0, b=0;
for(int i=lo;i<=hi;i++) {
if(s[i]=='R') r++;
if(s[i]=='B') b++;
}
if(r!=0&&b!=0) found=false;
}
else if(v==2) {
int r=0, b=0;
for(int i=lo;i<=hi;i++) {
if(s[i]=='R') r++;
if(s[i]=='B') b++;
}
if(r==0||b==0) found=false;
}
}
if(found) { used=true; craft(s); }
return;
}
solve(i+1, s+"R"); solve(i+1, s+"B");
}
int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
N=n; R=r; aa=a; bb=b; xx=x; solve(0, ""); bool f=true;
for(int l=0;l<r&&f;l++) {
if(x[l]==2) f=false;
}
if(f) {
for(int l=0;l<n;l++) cout<<"R";
return 1;
}
if(used) return 1;
return 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... |