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;
#define ar array
#define sz(v) int(v.size())
int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) {
string ans(n, '?'); ans[0] = 'R';
vector<vector<ar<int, 2>>> ev(n);
for (int i = 0; i < r; i++){
if (a[i] == b[i]){
if (x[i] == 2) return 0;
continue;
}
ev[a[i]].push_back({0, i});
ev[b[i]].push_back({1, i});
}
for (auto& v : ev) sort(v.begin(), v.end());
vector<bool> bad(r, 1);
set<int> c[2];
int cnt[2]={};
for (int i = 0; i < n; i++){
if (cnt[0]){
ans[i] = i?ans[i-1]:'R';
for (auto v : c[0]) bad[v]=0;
c[0].clear();
} else {
ans[i] = i?ans[i-1]^'R'^'B':'R';
for (auto v : c[1]) bad[v]=0;
c[1].clear();
}
for (auto e : ev[i]){
if (e[0] == 0){
c[x[e[1]]-1].insert(e[1]);
cnt[x[e[1]]-1]++;
} else {
c[x[e[1]]-1].erase(e[1]);
cnt[x[e[1]]-1]--;
}
}
}
for (auto v : bad) if (v) return 0;
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... |