-
Notifications
You must be signed in to change notification settings - Fork 0
/
GCDCompression.cpp
134 lines (119 loc) · 3.24 KB
/
GCDCompression.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ONLINE_JUDGE
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define db1(x) cout<<#x<<": "<<x<<"\n"
#define db2(x, y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define db3(x, y, z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"
#define db4(a, b, c, d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<"\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define fbo(a) find_by_order(a) //will give a-th largest element
#define ook(a) order_of_key(a) //will give no. of elements strictly lesser than a
#define setbits(x) __builtin_popcountll(x)
#define str string
#define dairymilk6969 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define eb emplace_back
#define pq priority_queue
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define ss second
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define sp(x,y) fixed<<setprecision(y)<<x
#define nl '\n'
#define sz(x) ((int)(x).size())
typedef map<ll, ll> mll;
typedef map<char, int> mci;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef map<pll, int> mpll;
typedef vector<pll> vpll;
typedef vector<vector<ll> > vv;
const ll N = 2e5 + 7;
const ll mod = 1e9 + 7;
const ll INF = 9223372036854775807 ;
template <class T> T chmax(T &a, const T &b) { return a = max(a, b); }
template <class T> T chmin(T &a, const T &b) { return a = min(a, b); }
/*bool cmp(const pair<ll, ll>& a, const pair<ll, ll>& b)
{
return a.ff < b.ff;
}*/
/***************End of Template****************/
/***************KEEP CODING*******************/
void solve(){
ll n;
cin>>n;
ll a[2*n];
fo(i,0,2*n){
cin>>a[i];
}
vpll odd,even;
fo(i,0,2*n){
if(a[i]%2){
odd.pb({a[i],i+1});
}
else{
even.pb({a[i],i+1});
}
}
if(odd.size()%2==0 and even.size()%2==0){
if(odd.size()!=0){
odd.pop_back();
odd.pop_back();
}
else{
even.pop_back();
even.pop_back();
}
if(odd.size()!=0){
for(ll i=0;i<odd.size()-1;i+=2){
cout<<odd[i].ss<<" "<<odd[i+1].ss<<nl;
}
}
if(even.size()!=0){
for(ll i=0;i<even.size()-1;i+=2){
cout<<even[i].ss<<" "<<even[i+1].ss<<nl;
}
}
return;
}
if(odd.size()%2!=0 and even.size()%2!=0){
odd.pop_back();
even.pop_back();
if(odd.size()!=0){
for(ll i=0;i<odd.size()-1;i+=2){
cout<<odd[i].ss<<" "<<odd[i+1].ss<<nl;
}
}
if(even.size()!=0){
for(ll i=0;i<even.size()-1;i+=2){
cout<<even[i].ss<<" "<<even[i+1].ss<<nl;
}
}
return;
}
}
int main()
{
dairymilk6969
#ifndef ONLINE_JUDGE
freopen("inputf.in", "r", stdin);
freopen("outputf.in", "w", stdout);
#endif
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll t;
cin>>t;
while(t--){
solve();
}
}