日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 芯聞號 > 充電吧
[導(dǎo)讀]Pattern lock security is generally used in Android handsets instead of a password. The pattern lock

Pattern lock security is generally used in Android handsets instead of a password. The pattern lock can be set by joining points on a 3 × 3 matrix in a chosen order. The points of the matrix are registered in a numbered order starting with 1 in the upper left corner and ending with 9 in the bottom right corner.

A valid pattern has the following properties:

A pattern can be represented using the sequence of points which it's touching for the first time (in the same order of drawing the pattern). And we call those points as active points.For every two consecutive points A and B in the pattern representation, if the line segment connecting A and B passes through some other points, these points must be in the sequence also and comes before A and B, otherwise the pattern will be invalid.In the pattern representation we don't mention the same point more than once, even if the pattern will touch this point again through another valid segment, and each segment in the pattern must be going from a point to another point which the pattern didn't touch before and it might go through some points which already appeared in the pattern.


Now you are given??active points, you need to find the number of valid pattern locks formed from those active points.

Input

There are multiple test cases. The first line of input contains an integer??indicating the number of test cases. For each test case:

The first line contains an integer??(3 ≤??≤ 9), indicating the number of active points. The second line contains??distinct integers?1,?2, …??(1 ≤??≤ 9) which denotes the identifier of the active points.

Output

For each test case, print a line containing an integer?, indicating the number of valid pattern lock.

In the next??lines, each contains??integers, indicating an valid pattern lock sequence. The??sequences should be listed in lexicographical order.

Sample Input

1
3
1?2?3

Sample Output

4
1?2?3
2?1?3
2?3?1
3?2?1



連接的可能數(shù)


#include#include#includeusing?namespace?std;

int?t,a[15],b[15],c[15][15],f[15],n,ans[500000][15],len;

void?print()
{
????int?i;
????len++;
????for?(i=1;?in)
????????print();
????else
????{
????????for(i?=?1;?i0)
????{
????????t--;
????????memset(a,0,sizeof(a));
????????memset(b,0,sizeof(b));
????????b[0]=1;
????????scanf("%d",&n);
????????for?(i=1;?i<=n;?i++)
????????{
????????????scanf("%d",&x);
????????????a[x]=1;??///X有沒有使用
????????????b[x]=1;??///X能否使用
????????}
????????len=0;
????????dfs(1);
????????printf("%dn",len);
????????for?(i=1;?i<=len;?i++)
????????{
????????????for?(j=1;?j<n;?j++)
????????????????printf("%d?",ans[i][j]);
????????????printf("%dn",ans[i][n]);
????????}
????}
????return?0;
}
本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉