#P15459. 【MX-X25-T3】『FeOI-5』qjyxfgms
【MX-X25-T3】『FeOI-5』qjyxfgms
Background
"qjyxfgms" is very likely an abbreviation made from the initial letters of Chinese pinyin. A common interpretation is: "请假一下发给秘书" ("qing jia yi xia fa gei mi shu", meaning "Please ask for leave and send it to the secretary".).
Problem Description
You are given a 01 sequence of length .
You can perform several operations on this sequence. In each operation, you may choose a position , and assign to .
You need to find the minimum number of operations to make all positions become .
Here, denotes the smallest natural number that does not appear in the set .
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , denoting the number of test cases. For each test case:
- The first line contains a positive integer .
- The second line contains integers , where .
Output Format
For each test case, output one line with a non-negative integer, representing the answer.
2
6
1 1 0 1 0 1
4
1 1 1 1
3
3
Hint
[Sample Explanation #1]
For the first test case:
- In the st operation, choose position . Since , the sequence becomes .
- In the nd operation, choose position . Since , the sequence becomes .
- In the rd operation, choose position . Since , the sequence becomes .
In total, operations are used to make all positions become . It can be proven that no solution with fewer operations exists.
[Constraints]
This problem uses bundled tests.
For all test cases, it is guaranteed that:
- ;
- ;
- .
::cute-table{tuack}
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| None | |||
| A | |||
| B | |||
| C | |||
| None |
Special Property A: .
Special Property B: .
Special Property C: it is guaranteed that the number of positions satisfying does not exceed .
Translated by ChatGPT 5