Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In the Name of Allah Most Gracious, Most Merciful//
- /*If you want something you've never had, you have to do something you never did.*/
- #include<bits/stdc++.h>
- using namespace std;
- #define pb push_back
- #define ll long long
- #define pii pair<int,int>
- #define pll pair<ll,ll>
- #define M 100007
- #define INF 1e9
- #define INFL 1e18
- #define PI acos(-1)
- #define mp make_pair
- //const int fx[]= {+1,-1,+0,+0};
- //const int fy[]= {+0,+0,+1,-1};
- //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
- //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
- //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
- //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
- int main()
- {
- // #ifndef ONLINE_JUDGE
- // freopen("input.txt","r",stdin);
- // freopen("output.txt","w",stdout);
- // #endif
- string p,q;
- cin>>p>>q;
- int p_len=p.size();
- int q_len=q.size();
- int j=0;
- int flag=0;
- for(int i=0;i<=q_len-p_len;i++)
- {
- for(j=0;j<p_len;j++)
- {
- if(p[j]!=q[j+i])
- {
- break;
- }
- }
- if(j==p_len)
- {
- flag=1;
- cout<<"YES"<<endl;
- break;
- }
- }
- if(!flag)
- {
- cout<<"NO"<<endl;
- }
- ///Before submit=>
- /// *check for integer overflow,array bounds
- /// *check for n=1
- }
Advertisement
Add Comment
Please, Sign In to add comment