#include "gift.h"
#include <bits/stdc++.h>
const int N = 5e5+10;
int sweep[N], mx[N];
int construct(int n, int r, std::vector<int> a, std::vector<int> b, std::vector<int> x) {
using namespace std;
string s = "";
for(int i = 0; i < r; ++i){
if(x[i] == 1) sweep[a[i]]++, sweep[b[i]]--;
}
char c[] = {'R', 'B'};
int cur = 0;
for(int i = 0; i < n; ++i){
sweep[i+1] += sweep[i];
mx[i] = -1;
s += c[cur];
if(sweep[i] == 0)cur ^= 1;
}
for(int i = 0; i < r; ++i){
if(x[i] == 2) mx[b[i]] = max(mx[b[i]], a[i]);
}
int last_change = -1;
for(int i = 0; i < n; ++i){
if(i > 0 && s[i] != s[i-1]) last_change = i-1;
if(last_change < mx[i]) return 0;
}
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... |