Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set<string> split(string s, int frag)
- {
- set<string> uni;
- int len = s.length();
- for(int i = 0; i < len; i+= frag)
- {
- uni.insert(s.substr(i, frag));
- }
- return uni;
- }
- bool check(string str,string out)
- {
- for(int i=0;i<out.size();i++)
- {
- if(str[i]!=out[i] && str[i]!='#')
- return 0;
- }
- return 1;
- }
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- cout.tie(NULL);
- string out;
- string s;
- cin>>s;
- int len = s.length();
- for(int i = len/2; i>1;--i)
- {
- set<string> uni = split(s,i);
- if(uni.size() == 1)
- {
- out = *uni.begin();
- break;
- }
- }
- int n=out.length();
- int i=0;
- string res="";
- while(i+n<len)
- {
- string str=s.substr(i,i+n);
- if(check(str,out))
- {
- res+=((i+1)-'0');
- }
- i++;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment