-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeautifulNumbers.java
More file actions
39 lines (38 loc) · 956 Bytes
/
BeautifulNumbers.java
File metadata and controls
39 lines (38 loc) · 956 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
28
29
30
31
32
33
34
35
36
37
38
39
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class BeautifulNumbers {
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int num;
num = Integer.parseInt(reader.readLine());
int[] index;
String[] input;
int n, pleft, pright, cand;
for (int i = 0; i<num; i++)
{
n = Integer.parseInt(reader.readLine());
index = new int[n];
input = reader.readLine().split(" ");
for (int j = 0; j < n; j++)
{
index[Integer.parseInt(input[j])-1] = j;
}
System.out.print("1");
pleft = pright = index[0];
for (int j=1; j<n; j++)
{
cand = index[j];
pleft = Math.min(cand, pleft);
pright = Math.max(pright, cand);
if (pright - pleft == j)
System.out.print("1");
else
System.out.print("0");
}
System.out.println();
}
}
}