• Array Product CodeForces


    #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 '
    '
    #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
    ",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
    ",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
    ",pos,v.back()),++cnt,s.erase(pos);
    		else printf("2 %d
    ",pos),++cnt,s.erase(pos);
    	}
    	if (cnt==n-1) return 0;
    	if (v.size()) {
    		printf("2 %d
    ",v.back()),++cnt,s.erase(v.back());
    	}
    	pr();
    }
    
  • 相关阅读:
    Redis-配置文件与持久化
    Redis-搭建简单集群
    python实现简单的统计
    Redis-三种数据结构与事务
    String 类的理解
    针对Java面试来学习JAVA内容,让你事半功倍
    jdbc实现原理
    一朋友的Java基础面试题及答案(TCP/IP部分)
    Java Docker容器化技术详解
    Java新手开源项目集合
  • 原文地址:https://www.cnblogs.com/uid001/p/10910987.html
Copyright © 2020-2023  润新知