Array Product CodeForces - 1042C (细节)
#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 (细节)的更多相关文章
- codeforces 1042c// Array Product// Codeforces Round #510(Div. 2)
题意:给出一个数组,2种操作:.1:x*y然后x消失,2:除掉x(2操作最多只能进行一次).问最大的结果的一种操作方式.逻辑题,看能不能想全面. 1先数好0,正,负的数量,zero,pos,neg.如 ...
- Array Product(模拟)
Array Product http://codeforces.com/problemset/problem/1042/C You are given an array aa consisting o ...
- codeforces 1042C Array Product【构造】
题目:戳这里 题意:n个数,两种操作,第一种是a[i]*a[j],删掉a[i],第一种是直接删除a[i](只能用一次)剩下的数序列号不变.操作n-1次,使最后剩下的那个数最大化. 解题思路: 正数之间 ...
- 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 ...
- Codeforces Round #510 (Div. 2) C. Array Product
题目 题意: 给你n个数,有两种操作,操作1是把第i个位置的数删去, 操作2 是把 a[ j ]= a[ i ]* a[ j ],把a[ i ]删去 .n-1个操作以后,只剩1个数,要使这个数最大 . ...
- 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 ...
- Array Division CodeForces - 808D (构造+实现)
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...
- CF1042C Array Product(贪心,模拟)
题目描述 You are given an array aa consisting of nn integers. You can perform the following operations w ...
- Array GCD CodeForces - 624D (dp,gcd)
大意: 给定序列, 给定常数a,b, 两种操作, (1)任选一个长为$t$的子区间删除(不能全部删除), 花费t*a. (2)任选$t$个元素+1/-1, 花费t*b. 求使整个序列gcd>1的 ...
随机推荐
- 第七章 python基础之函数,递归,内置函数
五 局部变量和全局变量 name='cyj' #在程序的一开始定义的变量称为全局变量. def change_name(): global name #global 定义修改全局变量. name=&q ...
- Netfilter 之 table、rule、match、target
概述 本文主要分析table,rule,match,target的作用和其数据结构之间的关系,为后面的匹配流程做铺垫,通过本文中代码流程的分析,可以得到如下的关系图: 详细分析 table iptab ...
- ORA-12899 导入失败
主要是目标数据库的字符集与导入文件的字符集不符 SQL>SHUTDOWN IMMEDIATE SQL>STARTUP MOUNT SQL>ALTER SYSTEM ENABLE RE ...
- pytorch-卷积基本网络结构-提取网络参数-初始化网络参数
基本的卷积神经网络 from torch import nn class SimpleCNN(nn.Module): def __init__(self): super(SimpleCNN, self ...
- 在vue项目中使用element-ui的Upload上传组件
<el-upload v-else class='ensure ensureButt' :action="importFileUrl" :data="upLoadD ...
- 关于微信XML解析存在的安全问题
---恢复内容开始--- 前言: 最近微信官方提出:微信支付商户,最近暴露的XML外部实体注入漏洞(XML External Entity Injection,简称 XXE),该安全问题是由XML组件 ...
- php版本:实现过滤掉广告、色情、政治相关的敏感词
现在网络上还是很乱,尤其充斥着各种广告.色情.政治相关的内容,很明显这是不符合我们国家的法律的,所以为了一个产品能够健康长久的活下去,最好还是采用一定的策略过滤或者提醒用户不要发这种内容.不过说起来容 ...
- 学校或公司转ISP -boardband (上网公司)注意事项记录
如果学校或公司轉boardband , 1. 要更新 domain IP (亦可以轉移domain 去新ISP公司, 要HKDNR 登入名稱和密碼,可問舊ISP即boardband 公司或域名管理方要 ...
- flask 之(七) --- 认证|文件|部署
登陆注册 说明: 令牌Token认证,在对HTTP形式的API发请求时,大部分情况我们不是通过用户名密码做验证,而是通过一个令牌[Token来做验证]. RESTful API无法使用Flask-Lo ...
- kubeadm安装集群系列(kubeadm 1.15.1)
kubeadm已经进入GA阶段,所以尝试使用kubeadm从零开始安装高可用的Kubernetes集群,并记录下过程和所有坑 本文基于kubeadm 1.15.1 目录 kubeadm安装集群系列-1 ...