1. // iostream is too mainstream
2. #include <cstdio>
4. #include <iostream>
5. #include <vector>
6. #include <set>
7. #include <map>
8. #include <string>
9. #include <queue>
10. #include <stack>
11. #include <algorithm>
12. #include <iomanip>
13. #define dibs reserve
14. #define OVER9000 1234567890
15. #define patkan 9
16. #define tisic 47
17. #define soclose 10e-7
18. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
19. #define chocolate win
20. #define ff first
21. #define ss second
22. #define abs(x) ((x < 0)?-(x):(x))
23. // mylittlepony
24. using namespace std;
25.
26. struct info {
27. int x,y,id;
28. bool q;
29.
30. info() {}
31. info(int a, int b, int t, int i) {q =(t > 0), x =a, y =b, id =i;}
32.
33. bool operator<(const info &I) const {
34. return x < I.x;}
35. };
36.
37. struct fin {
38. vector<int> T;
39. fin(int N) {T.resize(N+patkan,0);}
40.
41. int lastone(int x) {return x&(x^(x-1));}
42.
43. int get(int pos) {
44. int ret =0;
45. for(int i =pos+1; i > 0; i -=lastone(i)) ret +=T[i];
46. return ret;}
47.
48. void put(int pos) {
49. for(int i =pos+1; i < T.size(); i +=lastone(i)) T[i]++;}
50. };
51.
52. int main() {
53. cin.sync_with_stdio(0);
54. int N,a,b,c;
55. cin >> N;
56. vector<info> V;
57. map<int,int> M;
58. for(int i =0; i < N; i++) {
59. cin >> a >> b >> c;
60. M[a] =0; M[b] =0; M[c] =0;
61. if(a > b) swap(a,b);
62. if(a > c) swap(a,c);
63. if(b > c) swap(b,c);
64. V.push_back(info(b,a,0,i));
65. V.push_back(info(c,b,1,i));}
66. a =0;
67. ALL_THE(M,it) {it->ss =a; a++;}
68. sort(V.begin(),V.end());
69.
70. vector<int> ans(N);
71. fin F(3*N);
72. for(int i =0; i < V.size(); i++) {
73. V[i].y =M[V[i].y];
74. if(!V[i].q) {
75. F.put(V[i].y);
76. continue;}
77. ans[V[i].id] =F.get(V[i].y);}
78. a =0;
79. for(int i =0; i < N; i++) if(ans[i] == N) a++;
80. cout << a << "\n";
81. for(int i =0; i < N; i++) if(ans[i] == N) {
82. cout << i+1;
83. a--;
84. if(a > 0) cout << " ";}
85. cout << "\n";
86. return 0;}
87.
88. // look at my code
89. // my code is amazing
Success #stdin #stdout 0s 3440KB
stdin
4
4 1 11
5 8 9
2 12 6
7 3 10
stdout
3
2 3 4