武威 网站建设,拼多多关键词排名查询工具,绿化公司网站建设,网站建设 电话2023河南省赛组队训练赛#xff08;四#xff09; - Virtual Judge (vjudge.net) 约瑟夫最近开发了一款名为Pandote的编辑软件#xff0c;现在他正在测试#xff0c;以确保它能正常工作#xff0c;否则#xff0c;他可能会被解雇!Joseph通过实现对Pandote上字符串的复制和…2023河南省赛组队训练赛四 - Virtual Judge (vjudge.net) 约瑟夫最近开发了一款名为Pandote的编辑软件现在他正在测试以确保它能正常工作否则他可能会被解雇!Joseph通过实现对Pandote上字符串的复制和粘贴以及反向操作开始了他的测试。更具体地说在每一步中如果屏幕上的字符串是S他将按顺序进行以下操作。1. 选择长度为l(1≤l≤IS)的前缀则S可表示为AB (IA] 1)注意字符串B可以为空。2. 交换这两个部分得到字符串BA。3.反转整个字符串得到字符串(BA)但是由于Pandote的功能有限他在每一步中只能选择长度不同的前缀l1和l2。现在Joseph想知道他是否可以通过几个(可能是零)步骤将字符串S转换为T。输入输入的第一行给出了测试用例的数量T (1 T 5 × 105)。接下来是T测试用例。对于每个测试用例第一行包含字符串S第二行包含字符串T。S和T都由小写拉丁字母和[S] ITI组成。第三行包含两个整数l1和l2(1≤l1, l2≤IS1, l1 # 12)表示每一步可以选择的前缀长度。保证所有测试用例的|S]之和不超过5 × 105。
Sample 1
InputcopyOutputcopy 3
ljhelloh
hellohlj
2 4
thisisastr
htrtsasisi
3 5
abcde
bcdea
1 4yes
no
yes题解: 我们通过枚举样例可以发现如果连续两个l1或l2操作,原字符串是不变的
(假设l1 l2)
并且如果进行(l1,l2)
相当于把字符串向左(先l1后 l2) l1 - l2个单位
或向右移动(先l2 后l1) l1 - l2个单位
那么最终答案只可能会是
(l1,l2),l1,l2... 只在原字符串上进行向左或向右移动
l1,(l1,l2),(l1,l2)... 先进行一次l1,再同上
l2,(l1,l2),(l1,l2)... 先进行一次l2,在同上
由于我们要找循环节,所以字符串都变成二倍长度
然后哈希三种情况,看字符串T是否在三种情况中出现过
#includeiostream
#includealgorithm
#includestring
#includecstring
#includevector
#includemap
#includequeue
#includeset
using namespace std;
#define int long long
const int N 4e6 10;
typedef pairint, int PII;
string s,s1,s2,c;
int n,m,a,b;
int h1[N],h2[N],h[N],p[N];
int x 133331;
int mod 1e9 7;
int res;
int get(int h[],int l,int r)
{return (h[r] - h[l-1]*p[r-l1]%mod mod)%mod;
}
int check(int l,int r)
{if(get(h,l,r) res)return 1;if(get(h1,l,r) res)return 1;if(get(h2,l,r) res)return 1;return 0;}
void solve()
{cin s c a b;n s.size();s1 s.substr(a) s.substr(0,a);reverse(s1.begin(),s1.end());s2 s.substr(b) s.substr(0,b);reverse(s2.begin(),s2.end());s s s;s s;s1 s1 s1;s1 s1;s2 s2 s2;s2 s2;c c;res 0;p[0] 1;for(int i 1;i 2*n;i){p[i] (p[i-1]*x%mod);h[i] (h[i-1]*x%mod s[i])%mod;h1[i] (h1[i-1]*x%mod s1[i])%mod;h2[i] (h2[i-1]*x%mod s2[i])%mod;if(i n)res (res*x%mod c[i])%mod;}if(a b)swap(a,b);for(int i 1,j 1;j n;j){if(check(i,in - 1)){cout yes\n;return ;}i i n - a b;if(i n 1){i i%(n);if(!i)i n;}}for(int i 1,j 1;j n;j){if(check(i,in - 1)){cout yes\n;return ;}i i a - b;if(i n 1){i i%(n);if(!i)i n;}}cout no\n;
}signed main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);int t 1;cin t;
//scanf(%lld,t);while (t--) {solve();}
}
//3 F
//5 B
//6 F
//9 F
//10 B
//12 F
//15 FB
//18 FB
文章转载自: http://www.morning.rqmr.cn.gov.cn.rqmr.cn http://www.morning.llsrg.cn.gov.cn.llsrg.cn http://www.morning.nqwkn.cn.gov.cn.nqwkn.cn http://www.morning.gdpai.com.cn.gov.cn.gdpai.com.cn http://www.morning.hwtb.cn.gov.cn.hwtb.cn http://www.morning.jxcwn.cn.gov.cn.jxcwn.cn http://www.morning.xrrjb.cn.gov.cn.xrrjb.cn http://www.morning.tsqpd.cn.gov.cn.tsqpd.cn http://www.morning.qynpw.cn.gov.cn.qynpw.cn http://www.morning.bfwk.cn.gov.cn.bfwk.cn http://www.morning.nspbj.cn.gov.cn.nspbj.cn http://www.morning.bmzxp.cn.gov.cn.bmzxp.cn http://www.morning.rpms.cn.gov.cn.rpms.cn http://www.morning.xzgbj.cn.gov.cn.xzgbj.cn http://www.morning.gxeqedd.cn.gov.cn.gxeqedd.cn http://www.morning.tbqdm.cn.gov.cn.tbqdm.cn http://www.morning.kdnrc.cn.gov.cn.kdnrc.cn http://www.morning.sqqds.cn.gov.cn.sqqds.cn http://www.morning.hsflq.cn.gov.cn.hsflq.cn http://www.morning.zthln.cn.gov.cn.zthln.cn http://www.morning.hxfrd.cn.gov.cn.hxfrd.cn http://www.morning.dddcfr.cn.gov.cn.dddcfr.cn http://www.morning.ljbch.cn.gov.cn.ljbch.cn http://www.morning.rxpp.cn.gov.cn.rxpp.cn http://www.morning.mdmxf.cn.gov.cn.mdmxf.cn http://www.morning.rfgc.cn.gov.cn.rfgc.cn http://www.morning.tmjhy.cn.gov.cn.tmjhy.cn http://www.morning.hbxnb.cn.gov.cn.hbxnb.cn http://www.morning.easiuse.com.gov.cn.easiuse.com http://www.morning.thmlt.cn.gov.cn.thmlt.cn http://www.morning.jcfqg.cn.gov.cn.jcfqg.cn http://www.morning.mhxlb.cn.gov.cn.mhxlb.cn http://www.morning.kfwrq.cn.gov.cn.kfwrq.cn http://www.morning.sooong.com.gov.cn.sooong.com http://www.morning.xshkh.cn.gov.cn.xshkh.cn http://www.morning.ckzjl.cn.gov.cn.ckzjl.cn http://www.morning.nnjq.cn.gov.cn.nnjq.cn http://www.morning.twgzq.cn.gov.cn.twgzq.cn http://www.morning.xphcg.cn.gov.cn.xphcg.cn http://www.morning.rfzzw.com.gov.cn.rfzzw.com http://www.morning.yqrfn.cn.gov.cn.yqrfn.cn http://www.morning.qtsks.cn.gov.cn.qtsks.cn http://www.morning.nkpml.cn.gov.cn.nkpml.cn http://www.morning.kmbgl.cn.gov.cn.kmbgl.cn http://www.morning.nhzxr.cn.gov.cn.nhzxr.cn http://www.morning.pqcsx.cn.gov.cn.pqcsx.cn http://www.morning.fmgwx.cn.gov.cn.fmgwx.cn http://www.morning.ftmzy.cn.gov.cn.ftmzy.cn http://www.morning.jqkjr.cn.gov.cn.jqkjr.cn http://www.morning.mxlmn.cn.gov.cn.mxlmn.cn http://www.morning.rdxnt.cn.gov.cn.rdxnt.cn http://www.morning.fglth.cn.gov.cn.fglth.cn http://www.morning.kjyhh.cn.gov.cn.kjyhh.cn http://www.morning.mtktn.cn.gov.cn.mtktn.cn http://www.morning.ntffl.cn.gov.cn.ntffl.cn http://www.morning.ryxdf.cn.gov.cn.ryxdf.cn http://www.morning.ggjlm.cn.gov.cn.ggjlm.cn http://www.morning.yznsx.cn.gov.cn.yznsx.cn http://www.morning.nnhrp.cn.gov.cn.nnhrp.cn http://www.morning.jfbpf.cn.gov.cn.jfbpf.cn http://www.morning.pwbps.cn.gov.cn.pwbps.cn http://www.morning.bklkt.cn.gov.cn.bklkt.cn http://www.morning.tkrdg.cn.gov.cn.tkrdg.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.lpzyq.cn.gov.cn.lpzyq.cn http://www.morning.c7498.cn.gov.cn.c7498.cn http://www.morning.qbgdy.cn.gov.cn.qbgdy.cn http://www.morning.kndt.cn.gov.cn.kndt.cn http://www.morning.mxbks.cn.gov.cn.mxbks.cn http://www.morning.pqjpw.cn.gov.cn.pqjpw.cn http://www.morning.bqyb.cn.gov.cn.bqyb.cn http://www.morning.nptls.cn.gov.cn.nptls.cn http://www.morning.bnwlh.cn.gov.cn.bnwlh.cn http://www.morning.fbmjw.cn.gov.cn.fbmjw.cn http://www.morning.rtkgc.cn.gov.cn.rtkgc.cn http://www.morning.xjkr.cn.gov.cn.xjkr.cn http://www.morning.rqdx.cn.gov.cn.rqdx.cn http://www.morning.pbmg.cn.gov.cn.pbmg.cn http://www.morning.nqbkb.cn.gov.cn.nqbkb.cn http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn