跳到正文

个人记录

2026.9.13 NOIP 模拟赛复盘

abdf7788约 3 分钟
原文
文章信息与版本

文章信息

发布
2026年9月14日
收录
2026年9月14日
更新
2026年10月31日
篇幅
约 3 分钟

版本

  1. v1当前

2026.9.13 NOIP 模拟赛复盘

[TOC]

题得分总结
T1 ⽐赛30前面想了好久,最后打了20分暴力
T2 序列5在看完第一题后想了第二题,但没有太多思路,把dp想复杂了
T3 重排20打了暴力
T4 排序0在最后还是想看一下T1 T2 有没有做出来的可能,导致没有看
总分55在遇到难题时心态不好,导致整体出现了一些问题

T818443 序列

设数字 x 在 t 中第一次出现的位置为fst[x]fst[x],最后一次出现的位置为lst[x]lst[x] 对于在 t 中没有出现过的数字我们可以都选 对于在 t 中出现过的数字我们设当前数字为 i ,上一个数字为 j,则应满足lst[i]<=nxt[j]lst[i]<=nxt[j] 所以我们只需要考虑在b中出现过的数字的相邻两位的 lst 和 fst 的关系即可 所以 s’ 中的 fst 时递减的 所以我们可以模仿LIS的方式设计dp 我们设dp[i]dp[i]表示长度为 i 的 s’ 的最后一位的 nxt 的最大值 转移则是找到第一个小于于 lst[a[i]]lst[a[i]] 的 dp,将其的值与 nxt[a[i]]nxt[a[i]] 取max

C++
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5e5+5;
int dp[maxn];
vector<int>V[maxn];
int a[maxn];
int b[maxn];
int n,m; 
int lst[maxn];
int fst[maxn];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
//	freopen("seq.in","r",stdin);
//	freopen("seq.out","w",stdout); 
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=m;i++){
		cin>>b[i];
		lst[b[i]]=i;
		if(fst[b[i]]==0)fst[b[i]]=i;
	}
	int ans=0;
	dp[0]=1e9; 
	for(int i=1;i<=n;i++){
		if(lst[a[i]]==0)continue;
		int tmp=upper_bound(dp+1,dp+1+n,lst[a[i]],greater<int>() )-dp;
		dp[tmp]=max(dp[tmp],fst[a[i]]);
		ans=max(ans,tmp);
	}
	for(int i=1;i<=n;i++){
		if(lst[a[i]]==0)ans++;
	}
	cout<<ans;
}
原文