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;
int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) {
vector<int> same(n);
for (int i = 0; i < r; i++) {
if (x[i] == 1) {
same[a[i]]++;
same[b[i]]--;
}
}
for (int i = 0; i < n - 1; i++) same[i + 1] += same[i];
assert(same.back() == 0);
vector<int> diff(n);
for (int i = 0; i < n - 1; i++) diff[i + 1] = diff[i] + !same[i];
for (int i = 0; i < r; i++) {
if (x[i] == 1) assert(diff[a[i]] == diff[b[i]]);
if (x[i] == 2 && diff[a[i]] == diff[b[i]]) return 0;
}
string s(n, 'R');
for (int i = 0; i < n - 1; i++) {
if (!same[i]) s[i + 1] = s[i] ^ 'R' ^ 'B';
}
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... |