提交时间:2022-07-19 12:09:27

运行 ID: 52416

#include <iostream> #include <string> #include <algorithm> int main() { int t; std::cin >> t; while(t--){ std::string s, obj; int a, b; std::cin >> s >> obj >> a >> b; std::string origin = s; int prev = a; for(int i = 0; i < 100000; i++){ s = s.substr(prev) + s.substr(0, prev); std::reverse(s.begin(), s.end()); prev = (prev == a) ? b : a; if(s == obj){ std::cout << "yes" << std::endl; goto end; } } s = origin; prev = b; for(int i = 0; i < 100000; i++){ s = s.substr(prev) + s.substr(0, prev); std::reverse(s.begin(), s.end()); prev = (prev == a) ? b : a; if(s == obj){ std::cout << "yes" << std::endl; goto end; } } std::cout << "no" << std::endl; end: ; } return 0; }