Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cmath>
- #include <math.h>
- #include <vector>
- #include <queue>
- using namespace std;
- int main()
- {
- int a, b, c;
- cin >> a >> b >> c;
- vector<int> v(a + b + c + 1, 0), v2;
- for(int i = 0; i < a; i++) {
- int x;
- cin >> x;
- v[x] = 1;
- }
- v2 = v;
- int n = (a + b + c);
- vector<int> ans(a + b + c + 1, 10);
- for(int mask = 0; mask <= (1 << n); mask++) {
- int tmpb = b;
- int tmpc = c;
- for(int i = 1; i <= n; i++) {
- if(v[i] == 1) {
- continue;
- }
- if(mask & (1 << i)) {
- tmpb--;
- v[i] = 2;
- }
- else {
- tmpc--;
- v[i] = 3;
- }
- }
- bool ok = true;
- if(tmpb == 0 and tmpc == 0) {
- for(int j = 1; j + 1 <= n; j++) {
- if(v[j] == v[j+ 1] and v[j] != 0 and v[j + 1] != 0) {
- ok = false;
- break;
- }
- }
- if(ok) {
- ans = min(ans, v);
- }
- }
- v=v2;
- }
- for(int i = 1; i <= ans.size(); i++) {
- if(ans[i] == 1) {
- cout << 'A';
- }
- if(ans[i] == 2) {
- cout << 'B';
- }
- if(ans[i] == 3) {
- cout << 'C';
- }
- }
- if(ans[0] == 10) {
- cout << -1 << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement