結果

問題 No.1192 半部分列
ユーザー definedefine
提出日時 2020-08-05 14:59:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,381 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 206,368 KB
実行使用メモリ 33,120 KB
最終ジャッジ日時 2023-10-17 01:21:02
合計ジャッジ時間 4,892 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,732 KB
testcase_01 AC 2 ms
7,736 KB
testcase_02 AC 2 ms
7,732 KB
testcase_03 AC 2 ms
7,732 KB
testcase_04 AC 3 ms
7,736 KB
testcase_05 AC 3 ms
7,732 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 4 ms
7,732 KB
testcase_11 AC 3 ms
7,732 KB
testcase_12 RE -
testcase_13 AC 10 ms
26,512 KB
testcase_14 AC 12 ms
32,880 KB
testcase_15 AC 12 ms
33,016 KB
testcase_16 AC 9 ms
26,744 KB
testcase_17 AC 12 ms
33,120 KB
testcase_18 AC 5 ms
9,840 KB
testcase_19 AC 6 ms
14,144 KB
testcase_20 AC 54 ms
7,792 KB
testcase_21 AC 9 ms
24,304 KB
testcase_22 AC 5 ms
7,792 KB
testcase_23 RE -
testcase_24 AC 5 ms
14,028 KB
testcase_25 AC 8 ms
22,256 KB
testcase_26 AC 8 ms
22,256 KB
testcase_27 AC 12 ms
26,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

//Buffer Over Flow
string S,T;
int nexS[90005][26],nexT[90005][26];
int inc[90005];
signed main(){
	cin>>S>>T;
	assert(len(S)<=100000&&len(T)<=100000);
	rep(i,26){
		nexS[len(S)][i]=len(S);
		nexT[len(T)][i]=len(T);
	}
	rev(i,len(S)){
		rep(j,26)nexS[i][j]=nexS[i+1][j];
		nexS[i][S[i]-'a']=i;
	}
	rev(i,len(T)){
		rep(j,26)nexT[i][j]=nexT[i+1][j];
		nexT[i][T[i]-'a']=i;
	}
	int now=len(T);inc[len(S)]=now;
	rev(i,len(S)){
		now=max(-1ll,now-1);
		while(now>=0&&T[now]!=S[i])now--;
		inc[i]=now;
	}
	if(inc[0]!=-1){
		cout<<"-1\n";return 0;
	}
	string Ans;
	int curS=0,curT=0;
	while(curS<len(S)){
		rep(i,26){
			if(nexS[curS][i]==len(S))continue;
			if(nexT[curT][i]==len(T)){
				Ans+=('a'+i);
				cout<<Ans<<endl;return 0;
			}
			if(inc[nexS[curS][i]+1]>=nexT[curT][i]+1)continue;
			curS=nexS[curS][i]+1;
			curT=nexT[curT][i]+1;
			Ans+=('a'+i);
			break;
		}
	}
}
0