| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 (추가 시간 없음) | 512 MB | 38 | 19 | 16 | 48.485% |
Little Helena recently finished her first year of primary school. She is a model student, has straight A’s, and has a huge passion for mathematics. She is currently on a well-deserved vacation with her family, but she’s starting to miss her daily math homework. Luckily, her older brother decided to quench her intellectual thirst, and gave her the following problem.
A valid expression is defined recursively as follows:
? is a valid expression which represents a number.min($A$,$B$) and max($A$,$B$), where the former represents a function returning the smaller of its two arguments, while the latter represents a function returning the larger of its two arguments.For example, expressions min(min(?,?),min(?,?)) and max(?,max(?,min(?,?))) are valid according to the definition above, but expressions ??, max(min(?)) and min(?,?,?)are not.
Helena is given a valid expression containing a total of $N$ question marks. Each question mark is to be replaced with a number from the set ${1, 2, \dots, N}$ in such a way that each number from this set appears exactly once in the expression. In other words, the question marks are replaced by a permutation of the numbers from 1ドル$ to $N$.
Once the question marks have been replaced by numbers, the expression can be evaluated and its value will be an integer between 1ドル$ and $N$. Considering all the ways of assigning numbers to question marks, how many different values can Helena obtain after evaluating the expression?
The first and only line contains a single valid expression.
Output a single integer between 1ドル$ and $N,ドル the number of different values obtainable by evaluating the expression.
In all subtasks it holds that 2ドル ≤ N ≤ 1,000円,000円$.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | $N ≤ 9$ |
| 2 | 13 | $N ≤ 16$ |
| 3 | 13 | Each function in the expression has at least one question mark as an argument. |
| 4 | 30 | $N ≤ 1000$ |
| 5 | 34 | No additional constraints. |
min(min(?,?),min(?,?))
1
No matter how the numbers are assigned, the value of the resulting expression will always equal to the minimum of the set $\{1, 2, 3, 4\},ドル which is 1ドル$. Therefore, there is only one possible value.
max(?,max(?,min(?,?)))
2
The numbers 3ドル$ and 4ドル$ can be obtained as 4=max(4,max(3,min(2,1))) and 3=max(3,max(2,min(1,4))). It can be shown that values 1ドル$ and 2ドル$ are not attainable and so the answer is 2ドル$.
min(max(?,?),min(?,max(?,?)))
3