#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head #ifdef ONLINE_JUDGE
const int N = 1e6+10;
#else
const int N = 111;
#endif int n, cnt, a[N];
set<int> s;
vector<int> v, f;
void pr() {
v.clear();
for (int x:s) v.pb(x);
int sz = v.size();
REP(i,0,sz-2) {
printf("1 %d %d\n",v[i],v[i+1]),++cnt;
}
}
int main() {
scanf("%d", &n);
REP(i,1,n) {
scanf("%d",a+i);
if (!a[i]) v.pb(i);
if (a[i]<0) f.pb(i);
s.insert(i);
}
int sz = v.size();
if (sz==n) return pr(),0;
REP(i,0,sz-2) {
printf("1 %d %d\n",v[i],v[i+1]),++cnt,s.erase(v[i]);
}
if (f.size()%2) {
int mx = -2e9, pos;
for (int x:f) if (a[x]>mx) mx=a[x],pos=x;
if (v.size()) printf("1 %d %d\n",pos,v.back()),++cnt,s.erase(pos);
else printf("2 %d\n",pos),++cnt,s.erase(pos);
}
if (cnt==n-1) return 0;
if (v.size()) {
printf("2 %d\n",v.back()),++cnt,s.erase(v.back());
}
pr();
}

Array Product CodeForces - 1042C (细节)的更多相关文章

  1. codeforces 1042c// Array Product// Codeforces Round #510(Div. 2)

    题意:给出一个数组,2种操作:.1:x*y然后x消失,2:除掉x(2操作最多只能进行一次).问最大的结果的一种操作方式.逻辑题,看能不能想全面. 1先数好0,正,负的数量,zero,pos,neg.如 ...

  2. Array Product(模拟)

    Array Product http://codeforces.com/problemset/problem/1042/C You are given an array aa consisting o ...

  3. codeforces 1042C Array Product【构造】

    题目:戳这里 题意:n个数,两种操作,第一种是a[i]*a[j],删掉a[i],第一种是直接删除a[i](只能用一次)剩下的数序列号不变.操作n-1次,使最后剩下的那个数最大化. 解题思路: 正数之间 ...

  4. Codeforces Round #510 #C Array Product

    http://codeforces.com/contest/1042/problem/C 给你一个有n个元素序列,有两个操作:1,选取a[i]和a[j],删除a[i],将$a[i]*a[j]$赋值给a ...

  5. Codeforces Round #510 (Div. 2) C. Array Product

    题目 题意: 给你n个数,有两种操作,操作1是把第i个位置的数删去, 操作2 是把 a[ j ]= a[ i ]* a[ j ],把a[ i ]删去 .n-1个操作以后,只剩1个数,要使这个数最大 . ...

  6. Makes And The Product CodeForces - 817B (思维+构造)

    B. Makes And The Product time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  7. Array Division CodeForces - 808D (构造+实现)

    Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...

  8. CF1042C Array Product(贪心,模拟)

    题目描述 You are given an array aa consisting of nn integers. You can perform the following operations w ...

  9. Array GCD CodeForces - 624D (dp,gcd)

    大意: 给定序列, 给定常数a,b, 两种操作, (1)任选一个长为$t$的子区间删除(不能全部删除), 花费t*a. (2)任选$t$个元素+1/-1, 花费t*b. 求使整个序列gcd>1的 ...

随机推荐

  1. Amdahl定律和可伸缩性

    性能的思考 提升性能意味着可以用更少的资源做更多的事情.但是提升性能会带来额外的复杂度,这会增加线程的安全性和活跃性上的风险. 我们渴望提升性能,但是还是要以安全为首要的.首先要保证程序能够安全正常的 ...

  2. centos 下启动 rabbitmq 报错的解决

    安装 rabbitmq 后进行了一些配置,然后启动服务: service rabbitmq-server start 无法启动.通过 journalctl -xe 查看日志后,有如下日志: ... - ...

  3. Ubuntu开放指定端口

    一般情况下,ubuntu安装好的时候,iptables会被安装上,如果没有的话那就安装上吧 安装 在终端输入 sudo apt-get install iptables 添加规则 在终端输入 ipta ...

  4. SAP JCO3配置

    windows 环境设置 1.sapjco3.dll 需要与 sapjco3.jar 在同一目录 2.设置系统环境变量,将sapjco3所在目录加入系统环境变量 例如: 新建环境变量 变量名: JAV ...

  5. Linux学习—yum命令(转载)

    yum简介 yum( Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器. 基於RPM包管理,能够从指定的服务器自动 ...

  6. Centos7 搭建Svn+Apache服务器

    Svn客户端搭建 1.yum install subversion 2.查看安装版本 svnserve --version 3.创建SVN版本库目录 mkdir -p /opt/svn 4.创建版本库 ...

  7. iptable和tcpdump的先后顺序

    tcpdump是一个用来抓取linux网络数据包的工具,而iptables是linux上的防火墙工具,两者之间的顺序是: Wire -> NIC -> tcpdump -> netf ...

  8. Spark在Windows上调试

    1. 背景 (1) spark的一般开发与运行流程是在本地Idea或Eclipse中写好对应的spark代码,然后打包部署至驱动节点,然后运行spark-submit.然而,当运行时异常,如空指针或数 ...

  9. Python3 Selenium自动化web测试 ==> 第六节 WebDriver高级应用 -- 操作web页面的滚动条

    学习目的: 掌握页面元素定位以外的其他重要知识点. 正式步骤: 测试Python3代码 # -*- coding:utf-8 -*- from selenium import webdriver fr ...

  10. SpringBoot简历模板

    项目二:智慧学习-乐勤在线学习网(SpringBoot)◎ 开发模式:团队(8人)                 ◎ 开发周期:4个月◎ 开发环境:JDK1.8.Zookeeper        ◎ ...