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 <bits/stdc++.h>
#include "gift.h"
using namespace std;
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstdio>
#include <string>
vector<int>parent;
int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
parent.resize(n);
for(int l=0;l<n;l++)
parent[l]=l;
for(int i = 0; i < r; i++){
if(x[i] == 2) continue;
bool found = false;
int search = a[i];
vector<int>::iterator it;
int index;
do {
it = find(parent.begin(), parent.end(), search);
index = std::distance(parent.begin(), it);
if(index <= b[i]) {
found=true;
}
search++;
}
while(!found && it == parent.end());
if(parent[index] <= b[i]) {
while(index <= b[i] && index != n) {
parent[index] = b[i];
index++;
}
}
}
for(int i=0; i < r; i++) {
if(x[i] == 1) continue;
if(a[i] == b[i]) return 0;
int k = a[i];
while(k < b[i]-1) {
if(parent[k] == parent[k+1]) return 0;
k++;
}
}
string s ="R";
for(int i=1;i<n;i++)
{
if(parent[i] != parent[i-1])
if(s.back() == 'R')s += "B";
else s+= "R";
else s+= s.back();
}
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... |