fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define f(i, x, n) for(int i = x; i < (int)(n); ++i)
  4. #define ll long long
  5. const int N = 1000005;
  6. int q, a[200001], c[200001];
  7. pair <int, int> b[200001];
  8. int main(){
  9. int n;
  10. cin >> q;
  11. while(q--){
  12. cin >> n;
  13. for(int i = 1; i <= n; ++i){
  14. scanf("%d", &a[i]);
  15. b[i] = make_pair(a[i], i);
  16. }
  17. c[1] = 1;
  18. sort(b + 1, b + n + 1);
  19. int mn = 2000000, mx = 1;
  20. for(int i = 1; i <= n; ++i){
  21. mx = max(mx, b[i].second);
  22. mn = min(mn, b[i].second);
  23. if(mx - mn == i - 1){
  24. c[i] = 1;
  25. }
  26. else{
  27. c[i] = 0;
  28. }
  29. }
  30. for(int i = 1; i <= n; ++i){
  31. cout << c[i];
  32. }
  33. cout << endl;
  34. }
  35. return 0;}
  36.  
  37.  
Success #stdin #stdout 0s 4372KB
stdin
3
6
4 5 1 3 2 6
5
5 3 1 2 4
4
1 4 3 2
stdout
101011
11111
1001