http://codeforces.com/problemset/problem/1042/C

You are given an array n integers. You can perform the following operations with it:

  1. Choose some positions i-th cell;
  2. Choose some position no more than once and at any point of time, not necessarily in the beginning).

The number of elements decreases by one after each operation. However, the indexing of positions stays the same. Deleted numbers can't be used in the later operations.

Your task is to perform exactly any sequence of operations which leads to this maximum number. Read the output format to understand what exactly you need to print.

Input

The first line contains a single integer 2≤n≤2⋅105) — the number of elements in the array.

The second line contains −109≤ai≤109) — the elements of the array.

Output

Print k-th line should contain one of the two possible operations.

The operation of the first type should look like this: jk are the positions of the chosen elements.

The operation of the second type should look like this: ik is the position of the chosen element. Note that there should be no more than one such operation.

If there are multiple possible sequences of operations leading to the maximum number — print any of them.

Examples

Input
5
5 -2 0 1 -3
Output
2 3
1 1 2
1 2 4
1 4 5
Input
5
5 2 0 4 0
Output
1 3 5
2 5
1 1 2
1 2 4
Input
2
2 -1
Output
2 2
Input
4
0 -10 0 0
Output
1 1 2
1 2 3
1 3 4
Input
4
0 0 0 0
Output
1 1 2
1 2 3
1 3 4

Note

Let X be the removed number in the array. Let's take a look at all the examples:

The first example has, for example, the following sequence of transformations of the array: 30 are also correct.

The second example has, for example, the following sequence of transformations of the array: [X,X,X,40,X]. The following answer is also allowed:


1 5 3
1 4 2
1 2 1
2 3

Then the sequence of transformations of the array will look like this: [40,X,X,X,X].

The third example can have the following sequence of transformations of the array: [2,−1]→[2,X].

The fourth example can have the following sequence of transformations of the array: [0,−10,0,0]→[X,0,0,0]→[X,X,0,0]→[X,X,X,0].

The fifth example can have the following sequence of transformations of the array: [0,0,0,0]→[X,0,0,0]→[X,X,0,0]→[X,X,X,0].

 

简单的模板,要注意的就是只能删除一次

杂乱无章的代码。。。

 1 #include <iostream>
 2 #include<vector>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<set>
 6 using namespace std;
 7 
 8 int a[200005];
 9 vector<pair<int,int> >zheng,fu,ling;
10 
11 int main(){
12     std::ios::sync_with_stdio(false);
13     int n;
14     cin>>n;
15     set<int>s;
16     for(int i=1;i<=n;i++){
17         cin>>a[i];
18         if(a[i]==0){
19             ling.push_back(make_pair(a[i],i));
20         }
21         else if(a[i]>0){
22             zheng.push_back(make_pair(a[i],i));
23         }
24         else{
25             fu.push_back(make_pair(a[i],i));
26         }
27 
28     }
29     if((zheng.size()==0)&&(ling.size()>=0)&&(fu.size()==1)){
30         for(int i=2;i<=n;i++){
31             cout<<1<<" "<<i-1<<" "<<i<<endl;
32         }
33         return 0;
34     }
35     if((zheng.size()==0)&&(fu.size()==0)){
36         for(int i=1;i<ling.size();i++){
37             cout<<1<<" "<<ling[i-1].second<<" "<<ling[i].second<<endl;
38         }
39         return 0;
40     }
41     if(fu.size()>2){
42         sort(fu.begin(),fu.end());
43     }
44     int tmp1=-1,tmp2=-1,tmp3=-1,tmp4=-1;
45     int fulen;
46     if(fu.size()>0){
47         fulen=fu.size();
48         if(fu.size()%2){
49             fulen--;
50             tmp4=fu[fulen].second;
51         }
52         for(int i=1;i<fulen;i++){
53             cout<<1<<" "<<fu[i-1].second<<" "<<fu[i].second<<endl;
54         }
55         if(fu.size()==fulen)
56             tmp1=fu[fulen-1].second;
57         else if(fulen)
58             tmp1=fu[fulen-1].second;
59     }
60     if(ling.size()>0){
61         for(int i=1;i<ling.size();i++){
62             cout<<1<<" "<<ling[i-1].second<<" "<<ling[i].second<<endl;
63         }
64         tmp2=ling[ling.size()-1].second;
65     }
66     if(zheng.size()>0){
67         for(int i=1;i<zheng.size();i++){
68             cout<<1<<" "<<zheng[i-1].second<<" "<<zheng[i].second<<endl;
69         }
70         tmp3=zheng[zheng.size()-1].second;
71     }
72     if(tmp2!=-1&&tmp4!=-1){
73         cout<<1<<" "<<tmp2<<" "<<tmp4<<endl;
74         cout<<2<<" "<<tmp4<<endl;
75     }
76     else if(tmp2==-1&&tmp4!=-1){
77         cout<<2<<" "<<tmp4<<endl;
78     }
79     else if(tmp2!=-1&&tmp4==-1){
80         cout<<2<<" "<<tmp2<<endl;
81     }
82     if(tmp1!=-1&&tmp3!=-1){
83         cout<<1<<" "<<tmp1<<" "<<tmp3<<endl;
84     }
85 }
View Code

相关文章:

  • 2021-11-20
  • 2021-06-21
  • 2021-08-28
  • 2021-10-03
  • 2021-10-05
  • 2021-10-08
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-07-14
相关资源
相似解决方案