-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1361.cpp
More file actions
47 lines (40 loc) · 1.04 KB
/
1361.cpp
File metadata and controls
47 lines (40 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
using namespace std;
const ll INF = 1e9 + 7;
const ll DIV = 987654321;
string a, b;
int main()
{
fastio;
cin >> a >> b;
int n = a.size(), m = b.size();
for(int i = 0;i < m;i++){
string ta, tb;
int j = n + i - m;
if(j < 0) continue;
for(int t = 0;t<n;t++){
if(a[t] != '*') ta.push_back(a[t]);
else ta.append(i,'*');
}
for(int t = 0;t<m;t++){
if(b[t] != '*') tb.push_back(b[t]);
else tb.append(j,'*');
}
for(int t = 0;t < n + i - 1;t++){
if(ta[t] != tb[t] && ta[t] !='*' && tb[t]!='*') goto exit;
}
for(int t = 0;t < n + i - 1;t++){
if(ta[t] == '*' && tb[t] == '*'){
cout << 'A';
}
else if(ta[t] =='*') cout << tb[t];
else cout << ta[t];
}
return 0;
exit:;
}
cout << -1;
return 0;
}