Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <algorithm>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <cstring>
- using namespace std;
- char s[10005];
- int main() {
- ios_base::sync_with_stdio(false);
- int a, b, c;
- cin >> a >> b >> c;
- int x = a+b+c;
- vector<int> v;
- v.push_back(0);
- // for(int i = 1; i <= x; i++) {
- // s[i] = ' ';
- // }
- for (int i = 0; i < a; i++) {
- int k;
- cin >> k;
- v.push_back(k);
- s[k] = 'A';
- }
- // for (int i = 1; i < x+1; i++) {
- // cout << s[i];
- // }
- v.push_back(a + b + c + 1);
- int max = -1;
- for (int i = 0; i < v.size(); i++) {
- int tmpb = b;
- int tmpc = c;
- bool ok = true;
- int cnt = 0;
- for (int j = 1; j < v.size(); j++) {
- if (cnt < i) {
- cnt++;
- int range = (v[j] - v[j - 1]) - 1;
- if (range % 2 == 0) {
- if (tmpb >= range / 2 && tmpc >= range / 2) {
- tmpb -= range / 2;
- tmpc -= range / 2;
- } else {
- ok = false;
- break;
- }
- }
- if (range % 2 == 1) {
- if (tmpb >= range / 2 + 1 && tmpc >= range / 2) {
- tmpb -= range / 2 + 1;
- tmpc -= range / 2;
- } else {
- ok = false;
- break;
- }
- }
- } else {
- int range = (v[j] - v[j - 1]) - 1;
- if (range % 2 == 0) {
- if (tmpb >= range / 2 && tmpc >= range / 2) {
- tmpb -= range / 2;
- tmpc -= range / 2;
- } else {
- ok = false;
- break;
- }
- }
- if (range % 2 == 1) {
- if (tmpb >= tmpc && tmpb >= range / 2 + 1 && tmpc >= range / 2) {
- tmpb -= range / 2 + 1;
- tmpc -= range / 2;
- } else if (tmpc >= range / 2 + 1 && tmpb >= range / 2) {
- tmpb -= range / 2;
- tmpc -= range / 2 + 1;
- } else {
- ok = false;
- break;
- }
- }
- }
- }
- if (ok) {
- max = i;
- }
- }
- bool daliB = false;
- int cc = 0;
- for (int i = 1; i < v.size(); i++) {
- if (cc <= max) {
- cc++;
- daliB = true;
- for (int j = v[i - 1] + 1; j < v[i]; j++) {
- if (daliB) {
- s[j] = 'B';
- daliB = false;
- b--;
- } else if (!daliB) {
- s[j] = 'C';
- daliB = true;
- c--;
- }
- }
- } else {
- int range = (v[i] - v[i - 1]) - 1;
- if (range % 2 == 0) {
- daliB = true;
- for (int j = v[i - 1] + 1; j < v[i]; j++) {
- if (daliB) {
- s[j] = 'B';
- daliB = false;
- b--;
- } else if (!daliB) {
- s[j] = 'C';
- daliB = true;
- c--;
- }
- }
- } else {
- if (b >= c) {
- daliB = true;
- for (int j = v[i - 1] + 1; j < v[i]; j++) {
- if (daliB) {
- s[j] = 'B';
- daliB = false;
- b--;
- } else if (!daliB) {
- s[j] = 'C';
- daliB = true;
- c--;
- }
- }
- } else {
- daliB = false;
- for (int j = v[i - 1] + 1; j < v[i]; j++) {
- if (daliB) {
- s[j] = 'B';
- daliB = false;
- b--;
- } else if (!daliB) {
- s[j] = 'C';
- daliB = true;
- c--;
- }
- }
- }
- }
- }
- }
- if(max == -1){
- cout << -1;
- }
- else{
- for (int i = 1; i < x+1; i++) {
- cout << s[i];
- }
- }
- }
- //1viot for loop - Kolku od prvite rangeovi sakame da ni zapocnat so B
- //2riot for loop = Dali da mozeme da gi stavime i rangevi so B
- // i= 0 -- > sakam 0 rangeovi da ni pocne so b;
- // j=1 -- > 2 - 0 -- CBC
- // BCABCBACBCACBCACBCABCBACBCABCABCA
- // BCABCBABCBABCBACBCACBCACBCABCABCAProgram
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement