// https://atcoder.jp/contests/abc081/tasks/arc086_b
// <思维 构造>
// 两种情况非常容易构造 : 全整数情况 & 全负数情况, 仅需顺序累加即可
// 将其他情况转变为以上两种情况 :
// 找到n个数中的最大值 a[r] 和 最小值 a[l],
// 根据情况将所有数加上最大值或最小值, 使得转变为全正或全负情况
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <random>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 60;
int a[N];
void solv()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
int l = min_element(a+1, a+1+n) - a;
int r = max_element(a+1, a+1+n) - a;
cout << 2*n-1 << endl;
if (a[l] + a[r] >= 0)
{
for (int i = 1; i <= n; i ++) cout << r << ' ' << i << endl;
for (int i = 1; i < n; i ++) cout << i << ' ' << i+1 << endl;
}
else
{
for (int i = 1; i <= n; i ++) cout << l << ' ' << i << endl;
for (int i = n; i > 1; i --) cout << i << ' ' << i-1 << endl;
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
{
solv();
}
return 0;
}
标签:cout,int,情况,abc081d,using,include
From: https://www.cnblogs.com/o2iginal/p/17546938.html