-
Notifications
You must be signed in to change notification settings - Fork 0
/
D.cpp
57 lines (55 loc) · 1.03 KB
/
D.cpp
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
48
49
50
51
52
53
54
55
56
57
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int ara[300005];
int main()
{
fastio;
string s,t;
int n,m,i,dif=0;
cin>>s;
cin>>t;
n=s.size();
m=t.size();
string d;
for(i=0;i<m;i++)
d.push_back(s[n-1-i]);
reverse(d.begin(),d.end());
for(i=0;i<m;i++)
{
if(d[i]=='?' || t[i]=='?'){
ara[i]=0;
}
else if(d[i]!=t[i]){
ara[i]=1;
dif++;
}
}
if(dif==0)
cout<<"Yes\n";
else
cout<<"No\n";
for(i=0;i<m;i++)
{
if(s[i]=='?' || t[i]=='?'){
if(ara[i]==1)
{
dif--;
ara[i]=0;
}
}
else
{
if(ara[i]==0 && t[i]!=s[i])
dif++;
else if(ara[i]==1 && t[i]==s[i])
dif--;
}
if(dif>0)
cout<<"No\n";
else
cout<<"Yes\n";
}
return 0;
}