# H: Modelling Problems

There are no more than 10 unknown variable assignments `[x=?]`. Moreover, each `?` can either be 0 or 1. So, we can iterate over all 10-bit integers (0, ..., 1023) to consider all possible assignment combinations for `?` terms.

For each 10-bit integer `i`:

1. Create a hash map that maps variable names (chars) to values (ints)
2. Parse statements from the input string. This can just be done by checking all cases and handling each case separately:
   1. Assignment: map var name to a value (either a given value or some of two other vars)
   2. Assignment to an unknown: maintain a count `c` of the unknowns seen so far. Then, treat the unknown as the value `(i >> c) & 1` and increment `c` by 1. This sets the unknown to the c-th bit of `i`.
   3. Conditional: check if the condition is true based on entries in the map, and parse the assignments/assertions within the conditional if so
   4. Assertions: check if the variables specified have the same value. If not, immediately finish the test case and output `ASSERTIONS INVALID`

If all assertions pass for all `i`, output `ASSERTIONS ALWAYS HOLD`

{% hint style="info" %}
Note that variables have a default value of 0. In C++/Java, make sure to always check if a variable is in the map and use the value 0 otherwise. In Python, you can use a defaultdict to default variables not in the map to a value of 0.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://solutions.icpc.uclaacm.com/2021-tryout-solutions/tryout-1/h-modelling-problems.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
