Tuesday, March 22, 2016

UVa 200 - Rare Order

#include <bits/stdc++.h>
#define LL  long long
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define REV(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define pri(a) cout<<a<<endl
#define prii(a,b) cout<<a<<" "<<b<<endl
#define hi printf("Hello World\n")
#define WRITE(fn) freopen(fn, "w", stdout);
#define pcs printf("Case #%d:\n", ++cs);
using namespace std;

int main()
{
    string s[123456];
    int idx = 0, mxln = -1;

    while(cin>>s[idx++])
    {
        mxln = max(mxln, SZ(s[idx-1]));
        if(s[idx-1]=="#") break;
    }

    map<char,int> mp;
    char ch;

    int totalstring = idx - 1;

    REP(i,mxln)   /// nice koddur jaba? max string len porjonto
    {
        REP(j,totalstring)  /// pashe koddur jabe? total jotota string toto
        {
            if(i < SZ(s[j]))    // niche jotokkhon prjnto string lenth er moddhe thakbe totokkhn char prnt korbe
                ch = s[j][i];

            if(mp[ch]==0) printf("%c", ch), mp[ch]++;
        }
    }
    printf("\n");

    return 0;
}

No comments:

Post a Comment