题目太长了,付链接,直接点链接去看题目
代码
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
int a[45] = {0},n,t;
cin>>t;
while(t--)
{
cin>>n;
int ma = -1;
int f = 0;
for(int i = 1;i<=n;i++)
{
cin>>a[i];
if(a[i]>0)
{
ma = i;
f = 1;
}
}
if(f == 1)
{
cout<<5 + 2*(n-1)<<endl;
for(int i = 1;i<=5;i++)
{
cout<<ma<<" "<<ma<<endl;
}
for(int i = 2;i<=n;i++)
{
cout<<i<<" "<<ma<<endl;
cout<<i<<" "<<ma<<endl;
ma = i;
}
}
else
{
cout<<n-1<<endl;
for(int i = n;i>=2;i--)
{
cout<<i-1<<" "<<i<<endl;
}
}
}
}