이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) {
// clean up requirements
vector<tuple<int,int,int>> remaining_requirements {};
for (int i = 0; i < r; i++) {
if ((a[i] == b[i]) && x[i] == 2) {
return 0;
} else if (a[i] == b[i]) continue;
else {
remaining_requirements.push_back({a[i], b[i], x[i]});
}
}
// build all possibilities
vector<string> possibilities = {""};
for (int i = 0; i < n; i++) {
vector<string> new_possibilities = {};
for (string el : possibilities) {
new_possibilities.push_back(el + 'B');
new_possibilities.push_back(el + 'R');
}
possibilities = new_possibilities;
}
//check if possibility meets requirements
for (string s : possibilities) {
bool possible = true;
for (auto r : remaining_requirements) {
int beginning, ending, value;
tie(beginning, ending, value) = r;
if (value == 1) {
for (int i = beginning; i <= ending; i++) {
if (s[beginning] != s[i]) {
possible = false;
break;
}
}
} else {
bool two_colors = false;
for (int i = beginning; i <= ending; i++) {
if (s[beginning] != s[i]) {
two_colors = true;
break;
}
}
if (!two_colors) {
possible = false;
break;
}
}
if (!possible) break;
}
if (possible) {
craft(s);
return 1;
}
}
return 0;
}
# | 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... |