-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_GCD_Compression.java
More file actions
35 lines (34 loc) · 1.13 KB
/
B_GCD_Compression.java
File metadata and controls
35 lines (34 loc) · 1.13 KB
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
import java.util.Scanner;
public class B_GCD_Compression {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t --> 0) {
int n = sc.nextInt();
int i = -1;
int evenPosition = 0;
int oddPosition = 0;
int pairs = 0;
while(++i < 2*n) {
int temp = sc.nextInt();
if(pairs == n-1) continue;
if(temp%2 == 0) {
if(evenPosition > 0) {
int print = i+1;
System.out.println(evenPosition + " " + print);
evenPosition = 0;
pairs++;
} else evenPosition = i+1;
} else {
if(oddPosition > 0) {
int print = i+1;
System.out.println(oddPosition + " " + print);
oddPosition = 0;
pairs++;
} else oddPosition = i+1;
}
}
}
sc.close();
}
}