| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 319700 | northlake | Handcrafted Gift (IOI20_gift) | C++17 | 1620 ms | 493408 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<gift.h>
#include<bits/stdc++.h>
using namespace std;
bool one_color(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[0] != s[i]) {
return false;
}
}
return true;
}
bool two_color(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[0] != s[i]) {
return true;
}
}
return false;
}
bool check(string s, vector<pair<int,int>> requirements[]) {
int i = s.size()-1;
for (auto r : requirements[i]) {
int beginning = r.first; int value = r.second;
if (value == 1) {
if (!one_color(s.substr(beginning, i-beginning+1))) return false;
}
else {
if (!two_color(s.substr(beginning, i-beginning+1))) return false;
}
}
return true;
}
int construct(int n, int r, vector<int> a, vector<int> b, vector<int> x) {
// clean up requirements
vector<pair<int,int>> requirement_ending_at_i[n] {};
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 {
requirement_ending_at_i[b[i]].push_back({a[i], x[i]});
}
}
// build all possibilities and check if still meets requirements
vector<string> possibilities = {""};
for (int i = 0; i < n; i++) {
vector<string> new_possibilities = {};
for (string el : possibilities) {
if (check((el + 'B'), requirement_ending_at_i)) new_possibilities.push_back(el + 'B');
if (check((el + 'R'), requirement_ending_at_i)) new_possibilities.push_back(el + 'R');
}
possibilities = new_possibilities;
}
// build result
if (possibilities.size() > 0) {
craft(possibilities[0]);
return 1;
} else {
return 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
