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"
using namespace std;
int ims[500005],s[500005];
int construct(int n, int r,vector<int> a,vector<int> b,vector<int> x) {
vector<pair<int,int>>p[2];
for(int i=0;i<r;i++){
p[x[i]-1].push_back(make_pair(a[i],b[i]));
}
for(auto i:p[0]){
ims[i.first]++;
ims[i.second]--;
}
for(int i=1;i<n;i++)ims[i]+=ims[i-1];
for(int i=1;i<n;i++){
if(ims[i-1]==0)s[i]=1;
if(i>0)s[i]+=s[i-1];
}
for(auto i:p[1]){
if(s[i.second]==s[i.first])return 0;
}
string ans="R";
for(int i=0;i<n-1;i++){
if(ims[i]>0)ans+=ans.back();
else{
if(ans.back()=='R')ans+='B';
else ans+='R';
}
}
craft(ans);
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... |