fork download
  1. #include <bits/stdc++.h>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int t, n, minIndex, maxIndex, num, min, max;
  8. cin>>t;
  9. while(t--){
  10. cin>>n;
  11. int a[n];
  12. min = INT_MAX;
  13. max = INT_MIN;
  14. minIndex = maxIndex = -1;
  15. for(int i=0; i<n; i++){
  16. cin>>a[i];
  17. if(a[i]>max){
  18. max=a[i];
  19. maxIndex=i;
  20. }
  21. if(a[i]<min){
  22. min=a[i];
  23. minIndex=i;
  24. }
  25. }
  26. min = INT_MAX;
  27. int secMinIndex = -1;
  28. for(int i=0; i<minIndex; i++){
  29. if(a[i]<min){
  30. min=a[i];
  31. secMinIndex=i;
  32. }
  33. }
  34. max = INT_MIN;
  35. int secMaxIndex = -1;
  36. for(int i=maxIndex+1; i<n; i++){
  37. if(a[i]>max){
  38. max = a[i];
  39. secMaxIndex=i;
  40. }
  41. }
  42. for(int i=0; i<n; i++){
  43. if(i > minIndex && i < maxIndex){
  44. cout<<'0';
  45. }else if(i == minIndex || i == maxIndex){
  46. cout<<'1';
  47. }else {
  48. if(i>maxIndex){
  49. if(i<secMaxIndex)
  50. cout<<'0';
  51. else
  52. cout<<'1';
  53. }else if(i<minIndex){
  54. if(i>secMinIndex)
  55. cout<<'0';
  56. else
  57. cout<<'1';
  58. }
  59. }
  60. }
  61. cout<<endl;
  62. }
  63. return 0;
  64. }
Success #stdin #stdout 0s 5324KB
stdin
5
6
1 3 5 4 7 2
4
13 10 12 20
7
1 2 3 4 5 6 7
6
5 3 4 1 7 2
6
1 3 7 4 5 2
stdout
100011
1101
1000001
110111
101011