# Decision Non-Making Tree: Official Solution

*English translation by SOTA – AI Community of the Russian original. Organisers who would like this translation removed can email sota.ai.community@gmail.com.*

*Task 5 of the municipal stage (Moscow) of the All-Russian School Olympiad (VsOSh) 2025/26 in artificial intelligence, grades 9–11: official solution (the statement is in a separate file). Original: [ans-ai-9-11-mun-msk-25-26.pdf](https://vos.olimpiada.ru/upload/files/Arhive_tasks/2025-26/mun/ai/ans-ai-9-11-mun-msk-25-26.pdf).*

## Solution

In this task, we need to compute the probability of each leaf. Since each such probability is the product of three numbers (the choice probabilities at the vertices), for the comparison it is enough to compare the products of these numbers multiplied by 100 (that is, of the probabilities in per cent). Let us write out all 8 such products explicitly and, for each of them, remember the corresponding three-bit string. After that, we sort the pairs (probability, string) by probability and output the strings in the resulting order. This is the answer.

```cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int p1, p2, p3, p4, p5, p6, p7;
    cin >> p1 >> p2 >> p3 >> p4 >> p5 >> p6 >> p7;

    int p000 = p1 * p2 * p4;
    int p001 = p1 * p2 * (100 - p4);
    int p010 = p1 * (100 - p2) * p5;
    int p011 = p1 * (100 - p2) * (100 - p5);
    int p100 = (100 - p1) * p3 * p6;
    int p101 = (100 - p1) * p3 * (100 - p6);
    int p110 = (100 - p1) * (100 - p3) * p7;
    int p111 = (100 - p1) * (100 - p3) * (100 - p7);

    vector<pair<int, string>> v = {
        {p000, "000"},
        {p001, "001"},
        {p010, "010"},
        {p011, "011"},
        {p100, "100"},
        {p101, "101"},
        {p110, "110"},
        {p111, "111"}
    };

    sort(v.begin(), v.end());
    for (auto &[p, s] : v) {
        cout << s << '\n';
    }
    return 0;
}
```

**Maximum score for the task — 100**
