-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomino
More file actions
27 lines (24 loc) · 763 Bytes
/
Domino
File metadata and controls
27 lines (24 loc) · 763 Bytes
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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int upSum = 0, lowSum = 0;
boolean hasOddPair = false;
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
upSum += x;
lowSum += y;
if ((x + y) % 2 == 1) hasOddPair = true;
}
if (upSum % 2 == 0 && lowSum % 2 == 0) {
System.out.println(0);
} else if (upSum % 2 == 1 && lowSum % 2 == 1 && hasOddPair && n > 1) {
System.out.println(1);
} else {
System.out.println(-1);
}
sc.close();
}
}