Love Letters!


This is a companion discussion topic for the original entry at https://toph.co/p/love-letters

Print “Love is painful” If one of the admirers fulfill the condition or none of the admirers fulfill the condition ?

If no love letter reaches him that is. :wink:

Yeah, typing mistake in the question.

whats the problem in my code it should work!

bool comp(pair<char,int> a,pair<char,int> b){
    return a.first<b.first;
}
bool is(ll int n){
    fo1(2,sqrt(n)){
        if(n%i==0) return false;
    }
    return true;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //clock_t time=clock();
    ll int n;
    cin>>n;
    ll int d=1;
    while(n--){
        int r;string t;
        cin>>r>>t;
        string s=t;
        sort(all(s));
        string::iterator it=unique(s.begin(),s.end());
        s.resize(distance(s.begin(),it));
        vector<pair<char,int>> p;
        fo(0,s.size()){
            int tm=count(t.begin(),t.end(),s[i]);
            if(is(tm) && tm!=1) p.pb(make_pair(s[i],tm));
        }
        if(p.size()){
            sort(all(p),comp);
            cout<<"Case "<<d<<":"<<endl;
            fo(0,p.size()){
                cout<<p[i].first<<" = "<<p[i].second<<endl;
            }
        }
        else{
            cout<<"Case "<<d<<":"<<endl<<"Love is painful !";
        }
        d++;
    }
    //clock_t req=clock()-time;
    //cout<<"Time Took :"<<(float)req<<endl;
}

I have just given the functions related to the problem the headers and other essentials are included