Topic Link: Portal
The main topic: slightly;
Topic Idea: DP thought
After the data is read, it is traversed backwards, if we are looking for all sequences of a number string with a length of N of 1, then it can be represented as 1+ (a sequence with a length of n-1 at the beginning of any number)
Then we want to see which substrings in the sequence did not appear, that is (the sequence of any number beginning with the length of n-1) does not appear in the substring, with the DP array can be understood as dp[i]=x is, all 1~q of the DP array should be greater than or equal to X-1
#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>#include<cstring>#include<stack>#include<cctype>#include<queue>#include<string>#include<vector>#include<functional>#include<Set>#include<map>#include<climits>#defineLson Root<<1,l,mid#defineRson Root<<1|1,mid+1,r#defineFi first#defineSe Second#definePing (x, y) ((x-y) * (x-y))#defineMST (x, y) memset (x,y,sizeof (x))#defineMCP (x, y) memcpy (x,y,sizeof (y))using namespacestd;#defineGamma 0.5772156649015328606065120#defineMOD 1000000007#defineINF 0x3f3f3f3f#defineN 100005#defineMAXN 100005typedef pair<int,int>Pii;typedefLong LongLL;intn,vis[ -],k;intdp[ One];inta[100005];intMain () {intI,j,group; scanf ("%d%d",&n,&k); for(i=1; i<=n;++i) {scanf ("%d",&a[i]);} for(i=n;i>=1;--i) { intm=inf; for(j=1; j<=k;++j) M=min (m,dp[j]); Dp[a[i]]=m+1; } intm=inf; for(i=1; i<=k;++i) m=min (m,dp[i]); printf ("%d\n", m+1); return 0;}
Rnqoj (non-appearing substring)