Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <cstdlib>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  int N,A[50];
  PA MAX,MIN;
  MAX.first=-INF;
  MIN.first=INF;
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
    if(MAX.first<A[i]){
      MAX.first=A[i];
      MAX.second=i;
    }
    if(MIN.first>A[i]){
      MIN.first=A[i];
      MIN.second=i;
    }
  }
  if(abs(MAX)>=abs(MIN)){
    cout<<2*N-1<<endl;
    FOR(i,0,N){
      cout<<MAX.second<<" "<<i<<endl;
    }
    FOR(i,0,N-1){
      cout<<i+1<<" "<<i<<endl;
    }
  }else{
    cout<<2*N-1<<endl;
    FOR(i,0,N){
      cout<<MIN.second<<" "<<i<<endl;
    }
    FOR(i,0,N-1){
      cout<<i<<" "<<i+1<<endl;
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:9: error: no matching function for call to 'abs(std::pair<int, int>&)'
   44 |   if(abs(MAX)>=abs(MIN)){
      |      ~~~^~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:980:21: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'int'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |                 ~~~~^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:137:18: note:   no known conversion for argument 1 from 'std::pair<int, int>' to '__float128'
  137 |   abs(__float128 __x)
      |       ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to '__int128'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |                              ^
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:19: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'long double'
   79 |   abs(long double __x)
      |       ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:13: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'float'
   75 |   abs(float __x)
      |       ~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:14: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'double'
   71 |   abs(double __x)
      |       ~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:17: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'long long int'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |       ~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:12: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'long int'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |       ~~~~~^~~
a.cc:44:19: error: no matching function for call to 'abs(std::pair<int, int>&)'
   44 |   if(abs(MAX)>=abs(MIN)){
      |                ~~~^~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:980:21: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'int'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |                 ~~~~^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:137:18: note:   no known conversion for argument 1 from 'std::pair<int, int>' to '__float128'
  137 |   abs(__float128 __x)
      |       ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to '__int128'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |                              ^
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:19: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'long double'
   79 |   abs(long double __x)
      |       ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:13: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'float'
   75 |   abs(float __x)
      |       ~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:14: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'double'
   71 |   abs(double __x)
      |       ~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:17: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'long long int'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |       ~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:12: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'long int'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |       ~~~~~^~~