TOPIC

Wrong Answer 10%

Afif Al Mamun asked 3 years ago

Gettinng 10% WA. Need help!

#include <bits/stdc++.h>

using namespace std;

int main()
{   
    string tt, ss;
    map<string, int> m, res;
    m["Rerisson"] = 0;

    int a,b;
    cin>>a>>b;

    for(int i=0; i<a; i++)
    {
        cin>>tt>>ss;

        if(m.find(tt)!=m.end())
        {

        int deg = m[tt];

        if(m.find(ss)!=m.end() && m[ss] < m[tt])
            continue;

        if(deg < b)
        {
            m[ss] = deg+1;
            res[ss] = 1;
        }

        else    m[ss] = deg+1;

    }
    }

    cout<<res.size()<<"\n";
    for(map<string, int>::iterator it = res.begin(); it!=res.end(); it++)
        cout<<it->first<<"\n";
}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.