/* Author: ACboy Date: 2010-5-20 Result: AC Descripition: UVa 10131 Is Bigger Smarter? */ #include <iostream> #include <algorithm> using namespace std; struct elephant { int w; int iq; int order; }; elephant e[1100]; int c; int d[1100]; int fa[1100]; int cmp(elephant a, elephant b) { if (a.iq != b.iq) { return a.iq > b.iq; } else { return a.w < b.w; } } int main() { c = 0; int a, b; #ifndef ONLINE_JUDGE freopen("10131.txt", "r", stdin); #endif while (cin >> a >> b) { e[c].w = a; e[c].iq = b; e[c].order = c + 1; c++; } sort(e, e + c, cmp); int i, j; for (i = 0; i < c; i++) { d[i] = 1; } memset(fa, -1, sizeof(fa)); int result_value = 0; int position = 0; for (i = 1; i < c; i++) { int max_value = e[i].w; int value = 0; int pos = -1; for (j = 0; j < i; j++) { if (e[j].w < max_value && d[j] > value) { value = d[j]; pos = j; } } if (value != 0) { fa[i] = pos; d[i] = value + 1; if (d[i] > result_value) { result_value = d[i]; position = i; } } } cout << result_value << endl; int ans[1100]; int t = 0; while (fa[position] != -1) { ans[t++] = e[position].order; position = fa[position]; } ans[t++] = e[position].order; for (i = t - 1; i >= 0; i--) { cout << ans[i] << endl; } return 0; }