File tree Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Expand file tree Collapse file tree 1 file changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ // JAI BAJARANG BALI
2+
3+ // manitianajay45
4+
5+ // give me some sunshine, give me some rain , give me another chacne to grow up once again....
6+
7+ // sab moh maya hai....
8+
9+ #include < bits/stdc++.h>
10+ using namespace std ;
11+
12+ #define ll long long
13+
14+ #define mod 1000000007
15+
16+
17+ int main (){
18+ string s;
19+ cin>>s;
20+ ll n=s.length ();
21+
22+ ll x=0 ;
23+ ll y=0 ;
24+ vector<ll> zrr (n,0 );
25+ s+=' *' ;
26+ for (ll i=1 ;i<n;i++){
27+ zrr[i]=max (0ll ,min (zrr[i-x],(y-i+1 )));
28+
29+ while (i+zrr[i]<n && s[zrr[i]]==s[i+zrr[i]]){
30+
31+ x=i;
32+ y=i+zrr[i];
33+ zrr[i]++;
34+ }
35+
36+ }
37+ // for(ll i=0;i<n;i++){
38+ // cout<<zrr[i]<<" ";
39+ // }
40+ // cout<<endl;
41+
42+ for (ll i=1 ;i<=n-1 ;i++){
43+ ll j=i;
44+ bool flag=true ;
45+ while (j<n){
46+ if (zrr[j]<i && (j+zrr[j])<n){
47+ flag=false ;
48+ break ;
49+ }
50+ j+=i;
51+ }
52+ if (flag){
53+ cout<<i<<" " ;
54+ }
55+ }
56+
57+ cout<<n<<endl;
58+
59+ return 0 ;
60+
61+ }
You can’t perform that action at this time.
0 commit comments