fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int N;string S;
  6.  
  7. int main() {
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(NULL); cout.tie(NULL);
  10.  
  11. cin>>N;
  12. cin>>S;
  13.  
  14. for(int i=1;i<=N;i++){
  15. set<string> ms;
  16. bool flag=true;
  17.  
  18. for(int j=0;j+i-1<N;j++){
  19. string cur=S.substr(j,i);
  20. if(ms.find(cur)!=ms.end()){
  21. flag=false;
  22. break;
  23. }
  24.  
  25. ms.insert(cur);
  26. }
  27. if(flag){
  28. cout<<i;
  29. break;
  30. }
  31. }
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty