Cod sursa(job #2011288)

Utilizator stefdascalescuStefan Dascalescu stefdascalescu Data 15 august 2017 19:05:04
Problema Ordine Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include<bits/stdc++.h>
using namespace std;
ifstream f("ordine.in");
ofstream g("ordine.out");
int poz,l,v[30],q;
char c1[1000002];
char c2[1000002];
int main()
{
    f>>c1;
    l=strlen(c1);
    for(int i=0;i<l;++i)
        v[c1[i]-'a']++;
    int pc=-1;
    for(int i=0;i<26;++i)
        if(v[i]==l/2+1){
            pc=i;
            break;
        }
    if(pc){
        v[pc]=0;
        for(int i=0;i<26;++i)
            if(v[i])
            {
                char cz='a'+pc;
                g<<cz;
                cz='a'+i;
                g<<cz;
                --v[i];
                --i;
            }
    }
    g<<c2;
    return 0;
}