CF10D LCIS(线性DP)
2024-09-07 07:50:10
题意:\(LCIS\)输出方案
变迁の时刻,标记它
P.S:特判没\(LCIS\)的情况
//#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define R(a,b,c) for(register int a = (b); a <= (c); ++a)
#define nR(a,b,c) for(register int a = (b); a >= (c); --a)
#define Fill(a,b) memset(a, b, sizeof(a))
#define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))
#define ON_DEBUGG
#ifdef ON_DEBUGG
#define D_e_Line printf("-----------\n")
#define D_e(x) std::cout << (#x) << " : " <<x << "\n"
#define FileOpen() freopen("in.txt", "r", stdin)
#define FileSave() freopen("out2.txt", "w", stdout)
#define Pause() system("pause")
#include <ctime>
#define TIME() fprintf(stderr, "\nTIME :¡¡%.3lfms\n", clock() * 1000.0 / CLOCKS_PER_SEC)
#else
#define D_e_Line ;
#define D_e(x) ;
#define FileOpen() ;
#define FilSave ;
#define Pause() ;
#define TIME() ;
#endif
struct ios {
template<typename ATP> ios& operator >> (ATP &x) {
x = 0; int f = 1; char c;
for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
x *= f;
return *this;
}
}io;
using namespace std;
template<typename ATP> inline ATP Min(ATP a, ATP b) {
return a < b ? a : b;
}
template<typename ATP> inline ATP Max(ATP a, ATP b) {
return a > b ? a : b;
}
template<typename ATP> inline ATP Abs(ATP a) {
return a < 0 ? -a : a;
}
const int N = 507;
#define int long long
int a[N], b[N], f[N][N];
int n, m;
pair<int, int> from[N][N];
inline void DFS(int x, int y) {
if(!x) return;
DFS(from[x][y].first, from[x][y].second);
if(from[x][y].second != y) printf("%lld ", b[y]);
}
#undef int
int main() {
#define int long long
//FileOpen();
//freopen("okarin.in", "r", stdin);
//freopen("okarin.out", "w", stdout);
io >> n;
R(i,1,n) io >> a[i];
io >> m;
R(i,1,m) io >> b[i];
R(i,1,n){
int val=0;
pair<int,int> p = make_pair(0, 0);
R(j,1,m){
if(a[i] == b[j]){
f[i][j] = val + 1;
from[i][j] = p;
}
else{
f[i][j] = f[i - 1][j];
from[i][j] = from[i - 1][j];
}
if(b[j] < a[i])
if(val < f[i-1][j]){
p = make_pair(i - 1, j);
val = f[i - 1][j];
}
}
}
int now = 1;
R(i,2,m){
if(f[n][i] > f[n][now]){
now = i;
}
}
printf("%lld\n", f[n][now]);
if(f[n][now]) DFS(n,now);
return 0;
}
最新文章
- Android中处理崩溃异常
- HTML颜色、超链接设置
- 2.2 C#的注释
- SeleniumIDE从0到1 (Selenium IDE 安装)
- Unity 几种碰撞模式
- ubuntu 常用命令
- 绕过杀毒软件抓取windows密码
- 常用的JavaScript验证正则表达式1
- laravel5.2 移植到新服务器上除了“/”路由 ,其它路由对应的页面显示报404错误(Object not found!)———新装的LAMP没有加载Rewrite模块
- 利用 Dolby&#174; Digital Plus 提供优质音频体验
- C++面试题算法
- verilog之task用法实例
- 在JAVA中 System.getProperty 和 System.setProperty 方法.
- 【JSON学习之道】js操作JSON
- java I/O (一)
- bzoj3527: [Zjoi2014]力 卷积+FFT
- Amazon Publisher Studio让产品推广更简单
- JavaScript-手机中访问页面判断
- Elasticsearch之分词器的作用
- pycharm入门的简易使用教程
热门文章
- CXP 协议中upconnection 与downconnection的说明及其区别
- 深入浅出Nginx实战与架构
- C#/VB.NET 在PDF表格中添加条形码
- docker-compose 搭建 Prometheus+Grafana监控系统
- springboot available: expected at least 1 bean which qualifies as autowire candidate奇葩问题
- 2.2.1 用户态、内核态的形成 -《zobolの操作系统学习札记》
- IE让我首次遭受了社会的毒打
- SAP Column tree
- kali渗透测试阅读目录
- RPA 微信财务报销机器人 竹间智能