D - Match or Not
https://atcoder.jp/contests/abc287/tasks/abc287_d
思路
https://www.acwing.com/solution/content/166180/
对于t,分成两个段,
前段在s和t的最大前缀找,
后端在s和t的最大后缀找。
Code
https://atcoder.jp/contests/abc287/submissions/38576945
string s, t; int main() { cin >> s; cin >> t; int slen = s.size(); int tlen = t.size(); int prefixlen = 0; for(int i=0; i<tlen; i++){ char si = s[i]; char ti = t[i]; if (si == ti || si == '?' || ti == '?'){ prefixlen++; } else { break; } } int suffixlen = 0; for(int i=0; i<tlen; i++){ char si = s[slen-i-1]; char ti = t[tlen-i-1]; if (si == ti || si == '?' || ti == '?') { suffixlen++; } else { break; } } for(int x=0; x<=tlen; x++){ if(x<=prefixlen && tlen-x<=suffixlen){ cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
标签:contests,int,cin,https,abc287,Match From: https://www.cnblogs.com/lightsong/p/17091239.html