Language: C++

/*
Author: CNYALI_LK
LANG: C++
PROG: B.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WriteIntBuffer[1024];
template<class T>void write(T a,char end){
	int cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WriteIntBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WriteIntBuffer[cnt]);--cnt;}
	putchar(end);
}
int a[102424];
int s[1024],t[1024],cnt;
void add(int u,int v){
	s[++cnt]=u;t[cnt]=v;
}
void out(){
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;++i)printf("%d %d\n",s[i],t[i]);
}
int main(){
#ifdef cnyali_lk
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	int i;
	for(i=1;a[i]<=0&&i<=n;++i);
	for(int j=i-1;j>1;--j)add(j,j-1);
	if(i<=n){
		for(int j=1;j<=21;++j)add(i,i);
		while(i<n){
			++i;
			if(a[i]<0)add(i-1,i);
			add(i-1,i);
		}
	}
	out();
	return 0;
}

/*
Author: CNYALI_LK
LANG: C++
PROG: B.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WriteIntBuffer[1024];
template<class T>void write(T a,char end){
	int cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WriteIntBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WriteIntBuffer[cnt]);--cnt;}
	putchar(end);
}
int a[102424];
int s[1024],t[1024],cnt;
void add(int u,int v){
	s[++cnt]=u;t[cnt]=v;
}
void out(){
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;++i)printf("%d %d\n",s[i],t[i]);
}
int main(){
#ifdef cnyali_lk
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	int i;
	for(i=1;a[i]<=0&&i<=n;++i);
	for(int j=i-1;j>1;--j)add(j,j-1);
	if(i<=n){
		for(int j=1;j<=21;++j)add(i,i);
		while(i<n){
			++i;
			if(a[i]<0)add(i-1,i);
			add(i-1,i);
		}
	}
	out();
	return 0;
}



Compiler output:
a.cc:87:14: error: redefinition of 'const double eps'
   87 | const double eps=1e-8;
      |              ^~~
a.cc:13:14: note: 'const double eps' previously defined here
   13 | const double eps=1e-8;
      |              ^~~
a.cc:88:14: error: redefinition of 'const double pi'
   88 | const double pi=acos(-1.0);
      |              ^~
a.cc:14:14: note: 'const double pi' previously defined here
   14 | const double pi=acos(-1.0);
      |              ^~
a.cc:91:22: error: redefinition of 'template<class T> int chkmin(T&, T)'
   91 | template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
      |                      ^~~~~~
a.cc:17:22: note: 'template<class T> int chkmin(T&, T)' previously declared here
   17 | template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
      |                      ^~~~~~
a.cc:92:22: error: redefinition of 'template<class T> int chkmax(T&, T)'
   92 | template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
      |                      ^~~~~~
a.cc:18:22: note: 'template<class T> int chkmax(T&, T)' previously declared here
   18 | template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
      |                      ^~~~~~
a.cc:93:20: error: redefinition of 'template<class T> T sqr(T)'
   93 | template<class T>T sqr(T a){return a*a;}
      |                    ^~~
a.cc:19:20: note: 'template<class T> T sqr(T)' previously declared here
   19 | template<class T>T sqr(T a){return a*a;}
      |                    ^~~
a.cc:94:20: error: redefinition of 'template<class T> T mmin(T, T)'
   94 | template<class T>T mmin(T a,T b){return a<b?a:b;}
      |                    ^~~~
a.cc:20:20: note: 'template<class T> T mmin(T, T)' previously declared here
   20 | template<class T>T mmin(T a,T b){return a<b?a:b;}
      |                    ^~~~
a.cc:95:20: error: redefinition of 'template<class T> T mmax(T, T)'
   95 | template<class T>T mmax(T a,T b){return a>b?a:b;}
      |                    ^~~~
a.cc:21:20: note: 'template<class T> T mmax(T, T)' previously declared here
   21 | template<class T>T mmax(T a,T b){return a>b?a:b;}
      |                    ^~~~
a.cc:96:20: error: redefinition of 'template<class T> T aabs(T)'
   96 | template<class T>T aabs(T a){return a<0?-a:a;}
      |                    ^~~~
a.cc:22:20: note: 'template<class T> T aabs(T)' previously declared here
   22 | template<class T>T aabs(T a){return a<0?-a:a;}
      |                    ^~~~
a.cc:100:5: error: redefinition of 'int read()'
  100 | int read(){
      |     ^~~~
a.cc:26:5: note: 'int read()' previously defined here
   26 | int read(){
      |     ^~~~
a.cc:107:6: error: redefinition of 'char WriteIntBuffer [1024]'
  107 | char WriteIntBuffer[1024];
      |      ^~~~~~~~~~~~~~
a.cc:33:6: note: 'char WriteIntBuffer [1024]' previously declared here
   33 | char WriteIntBuffer[1024];
      |      ^~~~~~~~~~~~~~
a.cc:108:23: error: redefinition of 'template<class T> void write(T, char)'
  108 | template<class T>void write(T a,char end){
      |                       ^~~~~
a.cc:34:23: note: 'template<class T> void write(T, char)' previously declared here
   34 | template<class T>void write(T a,char end){
      |                       ^~~~~
a.cc:115:5: error: redefinition of 'int a [102424]'
  115 | int a[102424];
      |     ^
a.cc:41:5: note: 'int a [102424]' previously declared here
   41 | int a[102424];
      |     ^
a.cc:116:5: error: redefinition of 'int s [1024]'
  116 | int s[1024],t[1024],cnt;
      |     ^
a.cc:42:5: note: 'int s [1024]' previously declared here
   42 | int s[1024],t[1024],cnt;
      |     ^
a.cc:116:13: error: redefinition of 'int t [1024]'
  116 | int s[1024],t[1024],cnt;
      |             ^
a.cc:42:13: note: 'int t [1024]' previously declared here
   42 | int s[1024],t[1024],cnt;
      |             ^
a.cc:116:21: error: redefinition of 'int cnt'
  116 | int s[1024],t[1024],cnt;
      |                     ^~~
a.cc:42:21: note: 'int cnt' previously declared here
   42 | int s[1024],t[1024],cnt;
      |                     ^~~
a.cc:117:6: error: redefinition of 'void add(int, int)'
  117 | void add(int u,int v){
      |      ^~~
a.cc:43:6: note: 'void add(int, int)' previously defined here
   43 | void add(int u,int v){
      |      ^~~
a.cc:120:6: error: redefinition of 'void out()'
  120 | void out(){
      |      ^~~
a.cc:46:6: note: 'void out()' previously defined here
   46 | void out(){
      |      ^~~
a.cc:124:5: error: redefinition of 'int main()'
  124 | int main(){
      |     ^~~~
a.cc:50:5: note: 'int main()' previously defined here
   50 | int main(){
      |     ^~~~