fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void ptf (vector<int> &a){
  5. cout << a.size() << " ";
  6. sort(a.begin(), a.end());
  7. for (int x : a)
  8. cout << x << " ";
  9. cout << "\n";
  10. a.clear();
  11. }
  12.  
  13. int32_t main (){
  14. ios::sync_with_stdio(false); cin.tie(nullptr);
  15. if (fopen("test.inp", "r")){
  16. freopen("test.inp", "r", stdin);
  17. freopen("test.out", "w", stdout);
  18. }
  19. int n; cin >> n;
  20. vector<pair<int, int>> a(n + 1);
  21. for (int i = 1; i <= n; ++i){
  22. cin >> a[i].first;
  23. a[i].second = i;
  24. }
  25. sort(a.begin() + 1, a.end());
  26. {
  27. int i1 = a[n].first;
  28. int i2 = i1 + a[i1].first;
  29. if (i2 < n && a[i2].first <= n - i2){
  30. vector<int> v;
  31. for (int i = 1; i <= i1; ++i)
  32. v.push_back(a[i].second);
  33. ptf(v);
  34. for (int i = i1 + 1; i <= i2; ++i)
  35. v.push_back(a[i].second);
  36. ptf(v);
  37. return 0;
  38. }
  39. }
  40. {
  41. sort(a.begin() + 1, a.end(), greater<pair<int, int>>());
  42. for (int i1 = 1; i1 + a[1].first <= n; ++i1){
  43. int i2 = i1 + a[1].first;
  44. if (i2 < n && n - i2 >= a[i1 + 1].first && a[i2 + 1].first <= i1){
  45. vector<int> v;
  46. for (int i = 1; i <= i1; ++i)
  47. v.push_back(a[i].second);
  48. ptf(v);
  49. for (int i = i1 + 1; i <= i2; ++i)
  50. v.push_back(a[i].second);
  51. ptf(v);
  52. return 0;
  53. }
  54. }
  55. }
  56. cout << -1;
  57. }
  58.  
  59. // 4S 3D
  60.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
0 
0