You are given an array aa consisting of nn integers. You can perform the following operations with it:

  1. Choose some positions ii and jj (1≤i,j≤n,i≠j1≤i,j≤n,i≠j), write the value of ai⋅ajai⋅aj into the jj-th cell and remove the number from the ii-th cell;
  2. Choose some position ii and remove the number from the ii-th cell (this operation can be performed 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 n−1n−1 operations with the array in such a way that the only number that remains in the array is maximum possible. This number can be rather large, so instead of printing it you need to print 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 nn (2≤n≤2⋅1052≤n≤2⋅105) — the number of elements in the array.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (−109≤ai≤109−109≤ai≤109) — the elements of the array.

Output

Print n−1n−1 lines. The kk-th line should contain one of the two possible operations.

The operation of the first type should look like this: 1 ik jk1 ik jk, where 11 is the type of operation, ikik and jkjk are the positions of the chosen elements.

The operation of the second type should look like this: 2 ik2 ik, where 22 is the type of operation, ikik 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.

有一tuo数量为n的数列,你有两种操作,一种是删掉某个位置的值,一个是吧i位置的数乘到j位置上,再把i位置上的数删除,求怎么样操作能使最后留下的数最大~~。对了。。删除操作只能用一次;

通过贪心可得出,这个删除操作一定是用在删除0以及(奇数上那个的负数)而造成的影响上,所以把所有的0以及最大的负数(负数数量为奇数时)乘起来再删掉就行了。其他的按步骤操作即可。

#include<bits/stdc++.h>
using namespace std;
const int inf =0x3f3f3f3f;
int n,m[200005];
int main(){scanf("%d",&n);int fsum=0;int minn=-0x3f3f3f3f;int zero=0;for(int i=1;i<=n;i++){scanf("%d",&m[i]);if(m[i]==0){zero++;}if(m[i]<0){minn=max(minn,m[i]);fsum++;}}if(fsum%2){int za=inf;int a=inf;int spot=1,res=0;for(int i=1;i<=n;i++){if(m[i]==0||(m[i]==minn&&spot==1)){if(m[i]==minn){spot=0;}if(za==inf){za=i;}else{res++;printf("1 %d %d\n",za,i);za=i;}}else{if(a==inf){a=i;}else{res++;printf("1 %d %d\n",a,i);a=i;}}}if(res!=n-1){printf("2 %d\n",za);}}else{int za=inf;int a=inf;int res=0;for(int i=1;i<=n;i++){if(m[i]==0){if(za==inf){za=i;}else{res++;printf("1 %d %d\n",za,i);za=i;}}else{if(a==inf){a=i;}else{res++;printf("1 %d %d\n",a,i);a=i;}}}if(res!=n-1){printf("2 %d\n",za);}}return 0;
}

CodeForces - 1042C (emmmmmm水题)相关推荐

  1. Codeforces数据结构(水题)小结

    最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...

  2. B - Average Numbers CodeForces - 134A(水题,思维)

    You are given a sequence of positive integers a1, a2, -, an. Find all such indices i, that the i-th ...

  3. A - System Administrator CodeForces - 245A(水题)

    Polycarpus is a system administrator. There are two servers under his strict guidance - a and b. To ...

  4. Letters CodeForces - 978C(水题,low_bound()函数使用)

    水题,记录一下low_bound(*begin,*end,num),其中low-bound是指以num为下界,寻找第一个比num大或相等的元素的指针,通过减去*begin指针我们可以获得相应的下标. ...

  5. A - Greed CodeForces - 892A(水题)

    Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can ...

  6. Codeforces Divisibility【水题】

    A. Divisibility time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  7. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

  8. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

  9. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

最新文章

  1. 【Qt】通过QtCreator源码学习Qt(一):pro文件
  2. 深入JVM锁机制2-Lock
  3. C#面向集合的扩展(讨论)
  4. python装饰器-python中的装饰器常用于哪些应用场景
  5. 结对编程作业——四则运算
  6. CentOS7性能监控系统安装
  7. 面部识别辅助监控系统 人工智能为城市安全保驾护航
  8. js检测是否安装了flash插件
  9. 简便方法创建自签名证书
  10. JavaScript实现detectDirectedCycle检测定向循环算法(附完整源码)
  11. java中string类相等_Java中String类的常见面试题
  12. mysql 事件的作用_MySQL 事件
  13. Bailian3729 用set实现字符串的排序和查找【文本处理】
  14. 最多添加3个标签,每个标签最长6字,空格或逗号隔开
  15. smartadmin的php配置本,laravel-admin自动生成模块,及相关基础配置方法
  16. Android开发中需要用到的常见APP对应包名
  17. 国庆节未休假的你,领到了三倍的工资吗?
  18. flask-uploads文件上传
  19. 腾讯云通信、网易云通信、极光IM、阿里百川、容云通信国内云通信抉择之路 看云通信市场风云与掌控力 带腾讯云通信实战代码demo
  20. QQ农场启示录之:偷菜成本核算

热门文章

  1. [转载]深入Windows NT/2000模块的组织 - 专题安全方向{ Security Research Papers } - 邪恶八进制信息安全团队技术讨论组 努力为祖国的信息安全撑起一片蓝天
  2. java.swing 飞机大战小游戏
  3. 使用vagrant工具来管理和创建虚拟机
  4. 【源码】二分法的matlab实现
  5. C++上机实验2-1标准体重
  6. 解决小米蓝牙耳机无法被检测、无法连接的问题
  7. 瑞芯微RK3128盒子刷机提示测试设备失败的解决方法:MASKROM模式
  8. web表单设计:点石成金_Web设计趋势:如何确定有效方法
  9. SSM购物商城项目开发
  10. Android 快捷方式的创建