fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin>>t;
  7. while(t--)
  8. {
  9. int l; cin>>l;
  10. vector<int>v(l);
  11. vector<int>a(l);
  12. vector<int>b(l);
  13. for(int i=0;i<l;i++)
  14. {
  15. int x; cin>>x;
  16. v[i]=x;
  17. }
  18. int mid=(l/2);//2
  19. int j=0,c=0;
  20. int z=mid;
  21. while(l--)
  22. {
  23. if(v[j]<v[mid])
  24. { cout<<v[j]<<"<"<<v[mid]<<"\n";
  25. a[j]=v[j];
  26. j++;
  27. }
  28. else
  29. {
  30.  
  31. b[c]=v[mid];
  32. c++;
  33. mid++;
  34.  
  35. }
  36. //cout<<j<<"=="<<z<<"\n";
  37. if(j==z) {
  38. for(int i=c;i<l;i++)
  39. {
  40. b[c]=v[mid];
  41. mid++;
  42. c++;
  43. }
  44. break;
  45. }
  46. }
  47. if(j!=0&&c!=0)
  48. {
  49. cout<<j<<"\n";
  50. for(int i=0;i<j;i++) cout<<a[i]<<" ";
  51. cout<<"\n";
  52. cout<<c<<"\n";
  53. for(int i=0;i<c;i++) cout<<b[i]<<" ";
  54. cout<<"\n";
  55. }
  56. else cout<<"-1\n";
  57. }
  58. return 0;
  59. }
  60.  
Success #stdin #stdout 0.01s 5444KB
stdin
1
5
1 7 4 10 2
stdout
1<4
7<10
2
1	7	
2
4	10