Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
52323 Ender 修复符文 C++ 解答错误 10 1000 MS 1016 KB 874 2022-07-19 11:52:56

Tests(2/20):


#include <iostream> #define ll long long using namespace std; const int P = 9973; const int MOD = 1000000007; inline int abs(int x) { if(x < 0) return -x; return x; } ll Hash(string s) { ll hash = 0; int n = s.size(); for(int i(0);i < n;i++) hash = (hash * P % MOD + (s[i] - 'a')) % MOD; return hash; } string Move(string s,int step) { int n = s.size(); string sub = s.substr(n - step,step); s.erase(n - step,step); s = sub + s; return s; } int main() { int T; cin>>T; while(T--) { string s,t; int a,b,k,n; ll h1,h2; bool OK = 0; cin>>s>>t>>a>>b; n = s.size(); k = abs(a - b); h1 = Hash(t); for(int i(1);i <= n;i++) { s = Move(s,k); h2 = Hash(s); if(h1 == h2) { OK = 1; cout<<"yes"<<endl; break; } } if(!OK) cout<<"no"<<endl; } return 0; }


测评信息: