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;
bool used=false;
void solve(int i, string s, int n, int r, vector<int> a, vector<int> b, vector<int> x)
{
if(used) return;
if(i==n) {
bool found=true;
for(int l=0;l<r&&found;l++) {
int lo=a[l], hi=b[l], v=x[l];
if(v==1) {
int r=0, bl=0;
for(int i=lo;i<=hi;i++) {
if(s[i]=='R') r++;
if(s[i]=='B') bl++;
}
if(r!=0&&bl!=0) found=false;
}
else if(v==2) {
int r=0, bl=0;
for(int i=lo;i<=hi;i++) {
if(s[i]=='R') r++;
if(s[i]=='B') bl++;
}
if(r==0||bl==0) found=false;
}
}
if(found) { used=true; craft(s); }
return;
}
solve(i+1, s+"R", n, r, a, b, x); solve(i+1, s+"B", n, r, a, b, x);
}
int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
solve(0, "", n, r, a, b, x);
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... |