Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52615 wssdr 修复符文 C++ 内存超限 60 241 MS 262244 KB 620 2022-07-19 14:40:08

Tests(12/20):


#include<bits/stdc++.h> #define N 500005 using namespace std; int gcd(int a,int b){return !b?a:gcd(b,a%b);} string S,R; int T,a,b,m,n,f; inline string check(string c,int st){ string x(c.substr(0,st)),y(c.substr(st)); reverse(x.begin(),x.end());reverse(y.begin(),y.end()); return x+y; } int main(){ scanf("%d",&T); while(T--){ cin>>S>>R;scanf("%d%d",&a,&b); n=S.size();m=abs(a-b);f=0; for(int i(n/gcd(n,m));i>=1;--i){ string x(S.substr(n-m,m)),y(S.substr(0,n-m)); S=x+y;if(S==R||check(S,a)==R||check(S,b)==R){f=1;break;} } if(f) puts("yes"); else puts("no"); } return 0; }


测评信息: