文章

4

粉丝

44

获赞

5

访问

2.4k

头像
循环位移 题解:循环就是把数组“复制一遍”
P1912 厦门大学2018年机试
发布于2023年7月7日 21:44
阅读数 444

#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
unordered_map<string,bool> h;
int main()
{
    string a,b;
    cin>>a>>b;
    string tmp;
    tmp+=a;
    tmp+=a;
    int n=a.size();
    int sz=tmp.size();
    for(int i=0;i<n;i++)
    {
        string t;
        t.clear();
        int j=i;
        while(j-i+1<=n)
        {
            t+=tmp[j];
            j++;
        }
        //cout<<"*******"<<t<<endl;
        h[t]=true;
    }
    if(h[b])
        cout<<'Y'<<endl;
    else
...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发