hdu 1160 dp水
来源:互联网 发布:全网视频自动采集源码 编辑:程序博客网 时间:2024/06/09 15:37
/************************************************ *Author :jibancanyang *Created Time :一 4/ 4 01:43:38 2016 *题目类型:排序之后LIS.. *************************************************/#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>#include <stack>using namespace std;typedef pair<int, int> pii;typedef long long ll;typedef unsigned long long ull;vector<int> vi;#define xx first#define yy second#define sa(n) scanf("%d", &(n))#define rep(i, a, n) for (int i = a; i < n; i++)#define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++)const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e3 + 12;int dp[maxn], logs[maxn];struct node { int xx, yy; int num;}a[maxn];bool cmp(const node &a, const node &b) { return a.xx < b.xx;}int main(void){#ifdef LOCAL //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);#endif cin.sync_with_stdio(false); int cnt = 0; while (cin >> a[cnt].xx >> a[cnt].yy) a[cnt].num = cnt + 1, ++cnt; sort(a, a + cnt, cmp); rep (i, 0, cnt + 1) dp[i] = 1, logs[i] = -1; rep (i, 0, cnt) { for (int j = i - 1; j >= 0; j--) { if (a[j].yy > a[i].yy && a[i].xx > a[j].xx) { if (dp[i] < dp[j] + 1) { dp[i] = dp[j] + 1; logs[a[i].num] = a[j].num; } } } } int ans = 0, key = 0; rep (i, 0, cnt) { if (dp[i] > ans) { ans = dp[i]; key = a[i].num; } } stack<int> st; st.push(key); while (logs[key] != -1) { key = logs[key]; st.push(key); } cout << ans << endl; while (!st.empty()) { cout << st.top() << endl; st.pop(); } return 0;}
0 0
- hdu 1160 dp水
- hdu 1160 dp
- hdu 1160 DP
- hdu 1160 dp 入门
- HDU 1160 DP
- [DP-LIS] HDU 1160
- hdu 4526 水DP
- hdu 4856 水dp
- HDU 1003(水DP)
- HDU 2571 命运 水DP
- HDU 3555 水数位dp
- 【DP|水】HDU-2571 命运
- HDU 1087--DP--(水)
- HDU 4278 水~ 数位DP
- HDU 4722 (数位DP 水~)
- HDU 3652 (数位DP 水~)
- hdu 1160 FatMouse's Speed(水DP)
- HDU DP
- 每天laravel-20160704|CahceHit
- 要不要接这个项目?
- C#messagebox汇总
- 在MathType如何让括号随内容自动调整大小的技巧
- 数据库优化之表结构优化
- hdu 1160 dp水
- Vuforia SDK---- AR开发vuforia 相机自动对焦代码实现
- iOS 字体转换
- Myeclipse 导入别人的项目,汉字是乱码怎么办?
- 无处不在的二分查找
- 什么是ANR 如何避免它?
- 二叉树的遍历
- hdu1087 LIS变形
- 快速熟悉项目代码