8938: Almost Correct

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

Given a 01-sequence (sequence consisting only of 0s and 1s) s of length n, you need to find two arrays x and y such that
  • Array x and y are of equal length, and the length should not exceed 120.
  • 1≤xi<yi≤n for all 1≤i≤m, where mmm is the length of the two arrays.
  • Algorithm SORT(x,y) can sort all 01-sequences of length n correctly except for the given one. Here algorithm SORT(x,y) takes as input a 01-sequence a of length n, and is described as follows:
  • Iterate over all integers from 1 to m. For each integer i during the iteration, swap axi and ayi if axi>ayi.

输入格式

The input contains multiple test cases.
The first line of the input contains an integer T (1≤T≤10^4), the number of test cases.
For each test case, the first line contains an integer n (2≤n≤16).
The next line contains s, the 01-sequence of length n. It is guaranteed that s is not sorted, i.e., there exists some integers 1≤i<j≤n such that si=1 and sj=0.

输出格式


For each test case, output m (0≤m≤120) in the first line, indicating the length of array x and y.
In the i-th of the next m lines, print xi and yi (1≤xi<yi≤n) separated by a space.

输入样例 复制

2
2
10
3
110

输出样例 复制

0
2
1 2
2 3

分类标签