提交时间:2022-07-19 12:08:42
运行 ID: 52409
#include <bits/stdc++.h> using namespace std; int t; string s, r; int a, b; int main() { cin>>t; while(t--) { cin>>s>>r>>a>>b; string tmp = s; bool flag = false; int prev = a; // a first for(int i = 0; i < 1000000; ++i) { s = s.substr(prev) + s.substr(0, prev); reverse(s.begin(), s.end()); if(prev == a) prev = b; else prev = a; //cout<<s<<endl; if(s == r) { cout<<"yes"<<endl; goto end; } } prev = b; s = tmp; for(int i = 0; i < 1000000; ++i) { s = s.substr(prev) + s.substr(0, prev); reverse(s.begin(), s.end()); if(prev == a) prev = b; else prev = a; if(s == r) { cout<<"yes"<<endl; goto end; } } cout<<"no"<<endl; end: ; } return 0; }