麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

Educational Codeforces Round 17 C. Two strings(二分)

2019-11-11 04:55:37
字體:
來源:轉載
供稿:網友

C. Two strings

time limit per test:2 seconds

memory limit per test:256 megabytes

input:standard input

output:standard output

You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of the characters from b and make it empty.

Subsequence of string s is any such string that can be obtained by erasing zero or more characters (not necessarily consecutive) from string s.

Input

The first line contains string a, and the second line — string b. Both of these strings are nonempty and consist of lowercase letters of English alphabet. The length of each string is no bigger than 105 characters.

Output

On the first line output a subsequence of string a, obtained from b by erasing the minimum number of consecutive characters.

If the answer consists of zero characters, output ?-? (a minus sign).

Examples

Input hi bob

Output

Input abca accepted

Output ac

Input abacaba abcdcba

Output abcba

Note

In the first example strings a and b don’t share any symbols, so the longest string that you can get is empty.

In the second example ac is a subsequence of a, and at the same time you can obtain it by erasing consecutive symbols cepted from string b. 題意:給兩個字符串a.b,將b刪除連續的一部分后,成為a的子串,問這個最大子串,沒有輸出”-“. 題解:大神詳解 代碼:

#include <bits/stdc++.h>using namespace std;const int N=100005;char a[N],b[N];int lena,lenb,L,R;int needh[N],needl[N];int main(){ scanf("%s",a+1); scanf("%s",b+1); lena=strlen(a+1); lenb=strlen(b+1); for(int i=1;i<=lenb;i++) needh[i]=needl[i]=lena+1; int pos=1; L=lenb; R=1; for(int i=1;i<=lenb;i++) { while(pos<=lena&&a[pos]!=b[i])++pos; if(pos<=lena) needh[i]=pos; else { L=i-1; break; } ++pos; } pos=lena; for(int i=lenb;i>=1;i--) { while(pos>=1&&a[pos]!=b[i]) --pos; if(pos>=1) needl[i]=lena-pos+1; else { R=i+1; break; } --pos; } if(L<1&&R>lenb)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日本看片一区二区三区高清 | 最新av在线免费观看 | 国产精品毛片va一区二区三区 | 日本黄色免费观看视频 | 91在线色视频| 国产小视频在线 | 久久精品欧美一区二区 | 色网站综合| 免费观看一区 | 成人在线免费视频观看 | 中文国产在线视频 | 日本精品视频一区二区三区四区 | 男人久久天堂 | 精品成人国产在线观看男人呻吟 | 国产电影精品久久 | 91精品国产乱码久久桃 | 久久久久久久国产a∨ | 久久亚洲精品久久国产一区二区 | 国产人成精品一区二区三 | 日本aaaa片毛片免费观蜜桃 | 亚洲一区二区三区高清视频 | chinese乱子伦xxxx国语对白 | 国产成人在线视频 | 久久国产免费视频 | 性欧美极品xxxx欧美一区二区 | 午夜视频在线免费 | 国产一区二区三区色淫影院 | 成年人网站国产 | 天天夜夜草 | 亚洲欧美日韩精品久久 | 中文字幕在线永久视频 | 亚洲第一成人在线 | 国产精品久久久久久久久久了 | 精品国产一区二区在线 | 国产精选久久久 | 欧美色另类 | 香蕉视频1024| 欧美一级毛片一级毛片 | 欧美成人精品欧美一级 | 欧美成人精品不卡视频在线观看 | 一级一片免费 |