16.1112 Mock Exam T1

Source: Internet
Author: User

Encryption
"Problem description"
There is an unreasonable encryption method: randomly inserting characters anywhere in a string. corresponding to the
The unreasonable method of decryption is to delete exactly those characters that are randomly inserted from the string.
Given the original s and the encrypted string T, how many substrings can be decrypted to get the original S.
"Input Format"
Enter the first line containing a string T, and the second line contains a string s.
"Output Format"
The output line contains an integer that represents the number of substrings that can be decrypted to get the original S.
"Sample Input"
Abcabcabc
Cba
"Sample Output"
9
"Sample Interpretation"
with [?,?] Indicates the subscript at the beginning of the substring (numbered from 0), and these 9 scenarios are:
[0,6],[0,7],[0,8],[1,6],[1,7],[1,8],[2,6],[2,7],[2,8]
"Data size and conventions"
30% of data, |?| 1000.
For 100% of data, 1≤|t| ≤300,000,1≤s≤200.

1#include <cstdio>2#include <algorithm>3#include <cstring>4 using namespacestd;5 Long Longans;6 Const intN =301000, M = About;7 CharS[n], t[m];8 intN, M, f[m];9 intMain () {TenFreopen ("encrypt.in","R", stdin); OneFreopen ("Encrypt.out","W", stdout); Ascanf"%s%s", S +1, T +1); -n = strlen (S +1), M = strlen (T +1); -      for(inti =1; I <= N; ++i) { thef[0] =i; -          for(intj = m; J --j) -             if(S[i] = = T[j]) f[j] = f[j-1]; -Ans + =F[m]; +     } -printf"%i64d\n", ans); +     return 0; A}
1#include <cstdio>2#include <cstring>3#include <iostream>4#include <string>5 using namespacestd;6typedefLong Longll;7 Const intN = (int) 3e5 +Ten;8 Const intM = About;9 CharA[n +1], B[m +1];Ten intN, m, P[m +1]; OneInlineBOOLMoveintXintl) { A      for(; l < n && a[l]! = B[x]; + +l); -P[X] =l; -     returnL <N; the } - inline ll Move () { -     intpos = p[0]; -     if(!move (0, p[0] +1))return0LL; +      for(inti =1; I < m; ++i) -         if(!move (i, P[i-1] +1))return0LL; +     return(LL) (p[0]-POS) * (N-p[m-1]); A } at intMainintargcChar*argv[]) { -Freopen ("encrypt.in","R", stdin); -Freopen ("Encrypt.out","W", stdout); -scanf"%s%s", A, b); -n = strlen (a), M =strlen (b); -ll ans =0LL, cur; inp[0] = -1; -      while(cur =Move ()) toAns + =cur; +cout << ans <<Endl; - fclose (stdin); the fclose (stdout); *     return 0; $}

Idea: I will not, the great God to rescue ~~%%%%%%%%%%%%%%%%%%

Pay Data ~ Extract Password: XVHA

16.1112 Mock Exam T1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.