UVa 10635 - Prince and Princess(DP)
来源:互联网 发布:攻击app软件 编辑:程序博客网 时间:2024/06/18 09:10
题意:LCS。
思路:LIS。
#include <algorithm>#include <iostream>#include <sstream>#include <cstring>#include <cstdio>#include <vector>#include <string>#include <queue>#include <stack>#include <cmath>#include <set>#include <map>using namespace std;typedef long long LL;#define mem(a, n) memset(a, n, sizeof(a))#define ALL(v) v.begin(), v.end()#define si(a) scanf("%d", &a)#define sii(a, b) scanf("%d%d", &a, &b)#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)#define pb push_back#define eps 1e-8const int inf = 0x3f3f3f3f, N = 7e4 + 5, MOD = 1e9 + 7;int T, cas = 0;int n, p, q, x;int b[N], hs[N], ans[N];int main(){#ifdef LOCAL freopen("/Users/apple/input.txt","r",stdin);// freopen("/Users/apple/out.txt","w",stdout);#endifsi(T);while(T --) {siii(n, p, q);p ++, q ++;mem(hs, 0);for(int i = 1; i <= p; i ++) { si(x);hs[x] = i;}int idx = 0;for(int i = 1; i <= q; i ++) {si(x);if(hs[x]) b[idx ++] = hs[x];}int pos = 0;ans[0] = 0;for(int i = 0; i <= idx; i ++) {if(b[i] > ans[pos]) ans[++ pos] = b[i];else if(b[i] < ans[pos]) {int mid = lower_bound(ans, ans + pos, b[i]) - ans;ans[mid] = b[i];}}printf("Case %d: %d\n", ++ cas, pos);} return 0;}
0 0
- UVA 10635 Prince and Princess (dp + LCS)
- UVA 10635 Prince and Princess DP LIS
- Prince and Princess - UVa 10635 dp
- uva 10635 Prince and Princess(DP)
- UVa 10635 - Prince and Princess(DP)
- uva 10635 Prince and Princess(dp)
- uva 10635 Prince and Princess
- UVA 10635 Prince and Princess
- Uva-10635-Prince and Princess
- UVA 10635 Prince and Princess
- uva 10635 - Prince and Princess
- UVA 10635 Prince and Princess
- UVA 10635 Prince and Princess
- uva 10635 - Prince and Princess
- UVA - 10635 Prince and Princess
- uva 10635 - Prince and Princess
- UVA 10635 - Prince and Princess
- UVA 10635 Prince and Princess
- params可变参数
- Machine Learning week 8 quiz: programming assignment-K-Means Clustering and PCA
- MPEG-DASH VS. APPLE HLS VS. MICROSOFT SMOOTH STREAMING VS. ADOBE HDS
- gvim 命令补充
- CCActionEase(3)
- UVa 10635 - Prince and Princess(DP)
- 小米手机读取手机短信
- cc -MM 解决:如果makefile和源码不在同一个目录下,更新头文件却不能重建目标的问题
- 仿美团app,浮动layout滑动到顶部悬停效果
- windows 64bit selenium+python环境搭建
- 复习URLHttpConnection方式GET,POST方式链接网络解析uri
- C#引用C++Dll
- 多线程机制实例
- windows下安装nodejs