fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. const int mxN = 2e5 + 5;
  7. pair <pair<int, int>, int> a[mxN];
  8. pair <int, int> x[mxN], y[mxN], z[mxN];
  9.  
  10. int main() {
  11. int n;
  12. scanf("%d", &n);
  13. for(int i = 1; i <= n; ++i) {
  14. scanf("%d%d%d", &a[i].first.first, &a[i].first.second, &a[i].second);
  15. x[i] = make_pair(a[i].first.first, i);
  16. y[i] = make_pair(a[i].first.second, i);
  17. z[i] = make_pair(a[i].second, i);
  18. }
  19. sort(x + 1, x + n + 1);
  20. sort(y + 1, y + n + 1);
  21. sort(z + 1, z + n + 1);
  22. vector <int> answer;
  23. for(int i = 1; i <= n; ++i) {
  24. int First = a[i].first.first;
  25. int Second = a[i].first.second;
  26. int Third = a[i].second;
  27. int look;
  28. bool can = false;
  29. int idx = -1;
  30. if(x[1].second == i) {
  31. idx = x[2].second;
  32. look = x[2].first;
  33. }
  34. else {
  35. idx = x[1].second;
  36. look = x[1].first;
  37. }
  38. if(First > look)
  39. can |= (Second > a[idx].first.second || Third > a[idx].second);
  40. if(y[1].second == i) {
  41. idx = y[2].second;
  42. look = y[2].first;
  43. }
  44. else {
  45. idx = y[1].second;
  46. look = y[1].first;
  47. }
  48. if(Second > look)
  49. can |= (First > a[idx].first.first || Third > a[idx].second);
  50. if(z[1].first > look) {
  51. idx = z[2].second;
  52. look = z[2].first;
  53. }
  54. else {
  55. idx = z[1].second;
  56. look = z[1].first;
  57. }
  58. can |= (Second > a[idx].first.second || First > a[idx].first.first);
  59. if(!can)
  60. answer.push_back(i);
  61. }
  62. printf("%d\n", (int)answer.size());
  63. for(int &cur : answer)
  64. printf("%d ", cur);
  65. }
  66.  
Success #stdin #stdout 0s 4400KB
stdin
4
3 11 9
1 4 8
5 2 10
12 7 6
stdout
1
2