Advertisement
wrench786

Where Am I?

Jan 31st, 2022
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(){
  5.     int n;
  6.     cin>>n;
  7.  
  8.     string str;
  9.     cin>>str;
  10.  
  11.     for(int x=1;x<=n;x++){
  12.         bool flag=1;
  13.  
  14.         for(int i=1;i+x<=n;i++){
  15.             if(str.substr(0,x)==str.substr(i,x)){
  16.                 flag=0;
  17.                 break;
  18.             }
  19.         }
  20.  
  21.         if(flag){
  22.             cout<<x<<endl;
  23.             return;
  24.         }
  25.     }
  26. }
  27.        
  28.  
  29. int main()
  30. {
  31.     // freopen("whereami.in", "r", stdin);
  32.     // freopen("whereami.out", "w", stdout);
  33.     int tc=1;
  34.     //scanf("%d",&tc);
  35.  
  36.     while(tc--){
  37.         solve();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement