This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Coded by Chirath Nirodha
#include<bits/stdc++.h>
using namespace std;
#include "gift.h"
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long ll;
int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) {
string s(n, 'R');
int group[n];
for(int i=0;i<n;i++)group[i]=i;
vector<pair<int,pair<int,int> > > v;
for(int i=0;i<r;i++)v.PB(MP(x[i],MP(a[i],b[i])));
sort(v.begin(),v.end());
for(int i=0;i<r;i++){
int p=v[i].S.F,q=v[i].S.S;
if(v[i].F==1){
for(int j=q;j>=p;j--){
if(group[j]==group[p])break;
group[j]=group[p];
}
}
else if(group[p]==group[q])return 0;
}
for(int i=1;i<n;i++){
if(group[i]==group[i-1])s[i]=s[i-1];
else {
if(s[i-1]=='R')s[i]='B';
else s[i]='R';
}
}
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... |