1 solutions

  • 1
    @ 2023-6-1 22:16:03
    #include <bits/stdc++.h>
    using namespace std;
    int T,n,m,i,l,r,sum;
    string s,t;
    signed main(){
    	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    	cin>>T;
    	while (T--){
    		cin>>s>>t;
    		n=s.size(),s=" "+s+s;
    		m=t.size(),t=" "+t;
    		if (n<m){
    			cout<<"N\n";
    			continue;
    		}
    		for (i=1;i<=n;i++){
    			l=i,r=1,sum=0;
    			while (l<=i+n-1 && r<=m)
    				if (s[l]==t[r]) l++,r++,sum++;
    					else l++;
    			if (sum==m) break;
    		}
    		cout<<(i>n?"N\n":"Y\n");
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    8112
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    2
    Tags
    # Submissions
    4
    Accepted
    3
    Uploaded By