Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<algorithm>
- #include<vector>
- using namespace std;
- string temp, b;
- int d=0, arr[52], a, total=0;
- vector<int> count;
- void how_many_different_letters(){
- for(int i=0; i<temp.size(); i++){
- if(temp[i]!=temp[i+1])
- d++;
- }
- }
- void turn_arr_to_zero(){
- for(int u=0; u<52; u++)
- arr[u]=0;
- }
- void find_how_many_letters_of_each_type(){
- for(int k=j; k<j+i; k++){
- if(b[k]-'A'<32)
- arr[b[k]-'A']++;
- else
- arr[b[k]-'A'-6]++;
- }
- }
- void forming_count(){
- for(int u=0; u<52; u++){
- if(arr[u]!=0)
- count.push_back(arr[u]);
- }
- }
- void checking_if_letter_appear_an_equal_amount_of_times(){
- if(count.size()==d){
- int f=0;
- for(int k=0; k<count.size(); k++){
- if(count[k]!=count[k+1])
- f++;
- }
- if(f==0)
- total++;
- }
- }
- int main(){
- cin>>a;
- cin>>b;
- temp=b;
- sort(temp.begin(), temp.end());
- how_many_different_letters();
- //cout<<d<<endl;
- for(int i=1; i<=a; i++){
- for(int j=0; j<=a-i; j++){
- turn_arr_to_zero();
- find_how_many_letters_of_each_type();
- forming_count();
- checking_if_letter_appear_an_equal_amount_of_times();
- }
- }
- cout<<total;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement