-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSemifinals.java
52 lines (46 loc) · 1.37 KB
/
Semifinals.java
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
/* https://codeforces.com/contest/378/problem/B
#sorting #implementation
not care about whick k should be choosen in each semifinal.
first k element in each semifinals will be choose.
in each semifinals, in each element in k-th -> n will be choose
if it less than (n - k - 1) -th in the other simifinal.
*/
import java.util.Scanner;
public class Semifinals {
static void updateResult(int[] ip1, int[] ip2, char[] result1, char[] result2) {
int n = result1.length;
for (int i = n / 2; i < n; i++) {
if (ip1[i] < ip2[n - i - 1]) {
result1[i] = '1';
}
if (ip2[i] < ip1[n - i - 1]) {
result2[i] = '1';
}
}
}
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
// input
int[] ip1 = new int[n];
int[] ip2 = new int[n];
for (int i = 0; i < n; i++) {
ip1[i] = scanner.nextInt();
ip2[i] = scanner.nextInt();
}
scanner.close();
// result
char[] result1 = new char[n];
char[] result2 = new char[n];
int mid = n / 2;
for (int i = 0; i < n; i++) {
result1[i] = i < mid ? '1' : '0';
result2[i] = i < mid ? '1' : '0';
}
// update result
updateResult(ip1, ip2, result1, result2);
// show result
System.out.println(new String(result1));
System.out.println(new String(result2));
}
}