Untitled

 avatar
unknown
c_cpp
a year ago
3.3 kB
7
Indexable
#include <bits/stdc++.h>

using namespace std;

long long fact(int n) {
    long long ret = 1;
    for (int i = 1; i <= n; ++i) {
        ret *= i;
    }
    return ret;
}

long long power(int a, int b) {
    long long res = 1;
    for (int i = 0; i < b; ++i) {
        res *= a;
    }
    return res;
}

vector<string> T = {"A", "AB", "B", "O"};
// john = 0
// kaita = 1
// lauren = 2
// max = 3
//
enum NAMES {
    JOHN,
    KAITA,
    LAUREN,
    MAX
};
set<pair<string, string>> can_donate;

bool is_valid(vector<string> types) {
    bool john_kaita = can_donate.count({types[JOHN], types[KAITA]});
    bool kaita_john = !can_donate.count({types[KAITA], types[JOHN]});
    bool john_lauren = !can_donate.count({types[JOHN], types[LAUREN]});
    bool max_john = can_donate.count({types[MAX], types[JOHN]});
    bool max_kaita = can_donate.count({types[MAX], types[KAITA]});
    bool max_lauren = can_donate.count({types[MAX], types[LAUREN]});

    return john_kaita && kaita_john && john_lauren && max_john && max_kaita && max_lauren;
}

void go(vector<string> types) {
    if (types.size() == 4) {
        if (is_valid(types)) {
            for (auto t: types)
                cout << t << " ";
            cout << endl;
        }
        return;
    }
    for (auto type: T) {
        vector<string> tmp = types;
        tmp.push_back(type);
        go(tmp);
    }
}


enum NAMES_2 {
    DARIUS,
    DAPH,
    DITE,
    ROG,
    RACH,
    RAH
};

bool is_valid_2(vector<string> doners, vector<string> reciept) {
    for (int i = 0; i < 3; ++i) {
        if (!can_donate.count({doners[i], reciept[i]}))
            return false;
    }
    return true;
}

bool contains(string s, vector<string> vec) {
    for (auto ss: vec) {
        if (s == ss) {
            return true;
        }
    }
    return false;
}

int total = 0;
int valid = 0;

void go_2(vector<string> doners, vector<string> reciept) {
    if (doners.size() == 3) {
        total++;
        if (is_valid_2(doners, reciept)) {
            ++valid;
            for (auto t: doners)
                cout << t << " ";
            cout << "--";
            for (auto t: reciept)
                cout << t << " ";
            cout << endl;
        }
        return;
    }
    vector<string> opt_don = {"A", "B", "O"};
    vector<string> opt_rec = {"A", "B", "AB"};
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (contains(opt_don[i], doners) || contains(opt_rec[j], reciept)) {
                continue;
            }
            vector<string> tmp_d = doners;
            tmp_d.push_back(opt_don[i]);
            vector<string> tmp_r = reciept;
            tmp_r.push_back(opt_rec[j]);
            go_2(tmp_d, tmp_r);
        }
    }
}


int main() {
    can_donate.insert({"A", "A"});
    can_donate.insert({"A", "AB"});
    can_donate.insert({"AB", "AB"});
    can_donate.insert({"B", "B"});
    can_donate.insert({"B", "AB"});
    can_donate.insert({"O", "O"});
    can_donate.insert({"O", "A"});
    can_donate.insert({"O", "AB"});
    can_donate.insert({"O", "B"});

    go_2({}, {});
    cout << total << " " << valid << endl;


    return 0;
}


// 1 = 26.6666667 * 60
// 1.5 => 2400
// 1 => ?
Editor is loading...
Leave a Comment