Saturday, 1 June 2013

UVa 10420 - List of Conquests Solution

#include<iostream>
#include<cstdio>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
#include<deque>
#include<iterator>
#include<assert.h>
#include<bitset>
#include<climits>
#include<ctime>
#include<complex>

using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define PB push_back
#define PI acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define LL long long

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define KS printf("Case %d: ",kk++)

#define MOD 1000000007
#define MX 100010

int main()
{
    string s, line;
    int n;
    set<string>st;
    set<string>:: iterator it;
    map<string, int>mp;
    cin>>n;
    while(n--)
    {
        cin>>s;
        getline(cin, line);
        mp[s]++;
        st.insert(s);
        //cout<<"done"<<endl;
    }
    for(it=st.begin();it!=st.end();it++)
        cout<<*it<<" "<<mp[*it]<<endl;
    return 0;
}

2 comments:

  1. i can't understand your code.. please do you explain it to me?? line by line... thanks in advance..

    ReplyDelete
    Replies
    1. To understand this you have to go through the terms MAP and SET from STL in C++.After that hopefully you will understand.

      Delete