feat(codeforces): 1017
This commit is contained in:
parent
375a673932
commit
f366180f50
31 changed files with 857 additions and 1 deletions
43
codeforces/1017/d.cc
Normal file
43
codeforces/1017/d.cc
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
int x;
|
||||
std::cin >> x;
|
||||
|
||||
while (x--) {
|
||||
std::string p, s;
|
||||
std::cin >> p >> s;
|
||||
|
||||
size_t pi = 0;
|
||||
size_t si = 0;
|
||||
while (pi < p.size() && si < s.size()) {
|
||||
if (p[pi] != s[si]) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto TO_MATCH = p[pi];
|
||||
|
||||
size_t LEFT_POS_CHANGE = 0;
|
||||
size_t RIGHT_POST_CHANGE = 0;
|
||||
while (p[pi] == TO_MATCH) {
|
||||
++LEFT_POS_CHANGE;
|
||||
if (++pi == p.size())
|
||||
break;
|
||||
}
|
||||
while (s[si] == TO_MATCH) {
|
||||
++RIGHT_POST_CHANGE;
|
||||
if (++si == s.size())
|
||||
break;
|
||||
}
|
||||
// clamp delta
|
||||
if (RIGHT_POST_CHANGE < LEFT_POS_CHANGE ||
|
||||
RIGHT_POST_CHANGE > 2 * LEFT_POS_CHANGE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << (pi == p.size() && si == s.size() ? "YES\n" : "NO\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue