০৩ সেপ্টেম্বর ২০১৬

Upcomming_Eid_Ul_AZHA_Programmming_Contest A. Helping Tool

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#include<map>
//#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf

typedef long long LL;
typedef long L;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, int> mpcii;
typedef map<char , bool> mpcb;
typedef vector<char>vc;

int main()
{
    fast;
    string s;
    //mpcii mp;
    //mpcb mpc;
    vc v;
    while(cin >> s)
    {
        //mp.clear();
        //mpc.clear();
        v.clear();

        int len = s.length() , i=0;

        //int x = 200000; cout << x;

       for(i=0; i<len; i++)
       {
           v.push_back(s[i]);
       }

       i=0;

       len=v.size(); //cout << "len1 = " << len << "\n";

       for(; i<len-1; i++)
       {
           if(v[i] == v[i+1])
           {
               int j = i;

               len-=2;

               for(; j<len; j++)
               {
                   v[j] = v[j+2];
               }

//               if(!mpc[v[i]] and !mpc[v[i+1]])
//               {
//                   mpc[s[i]] = true;
//                   mpc[s[i+1]] = true;
//               }

               //for(int k=0; k<v.size()-2; k++) cout << v[k] << " ";
               //cout << "\n";

               i=-1;
           }
       } //cout << "len = " << len << "\n";

       if(len <= 0) cout << "-1";

       else
       {
           for(i=0 ; i<len; i++) cout << v[i];
       }

       cout << "\n";
    }

    return 0;
}

// xraccabccbry

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন