Rezultati

Up. imeNalogaJezikRezultatČas oddaje
Deathmask Plezalne smeri C++ 100/100OK 13. okt '18 @ 12:36

Test Točke Porabljen spomin Porabljen čas Status
#1 50/50 3,199 MiB 0,000 s OK
#2 50/50 3,207 MiB 0,001 s OK

Ocenjevani program (main.cpp):
#include <iostream>
#include <algorithm>

using namespace std;
string rm(string s){
string tmp="";
    for (int i=0;i<s.length()-1;i++){
            tmp+=s[i];
    }
    return tmp;
}
bool sm(string a,string b){
int i=0;
    while (a[i]==b[i])
    i++;

    if (a[i]<b[i])
    return true;
    else
    return false;

}
void sr(int is, int n,string Arr1[]){
for (int i=is;i<n;i++){

        int mini=i;
        for (int j=i;j<n;j++){

            if (sm(Arr1[j],Arr1[mini])){
                mini=j;
            }

        }
        swap(Arr1[i],Arr1[mini]);
    }


}

void ms(string Arr1[],double Arr[], int n){




    for (int i=0;i<n;i++){

        int mini=i;
        for (int j=i;j<n;j++){

            if (Arr[j]<Arr[mini]){
                mini=j;
            }

        }
        swap(Arr[i],Arr[mini]);
        swap (Arr1[i],Arr1[mini]);
    }


}
int main()
{
    int n;
    cin>>n;
    string a[n], b[n];

    for(int i=0;i<n;i++){
        cin>>a[i];
        cin>>b[i];
    }
    string tran[13]={"","I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII"};
    double bt[n];
    for (int i=0;i<n;i++){
        string cs;
        if (b[i][b[i].length()-1]=='+' || b[i][b[i].length()-1]=='-'){
            cs=rm(b[i]);
        }
        else{
        cs=b[i];
        }

        int ci;
        for (int j=1;j<=12;j++){
            if (tran[j]==cs)
              {
                ci=j;
                break;
              }
        }
        if (b[i][b[i].length()-1]=='+'){
        bt[i]=ci+0.1;
        }
        else if (b[i][b[i].length()-1]=='-'){
        bt[i]=ci-0.1;
        }
        else{
        bt[i]=ci;
        }
    }

    ms(a,bt,n);
    for (int i=0;i<n-1;i++){

        if (bt[i]==bt[i+1]){
        int i1=i+1;
            while (i1<n && bt[i1]==bt[i]){
                i1++;
            }
            sr(i,i1,a);
            i=i1-1;
        }

    }

    for(int i=0;i<n;i++){

    cout<<a[i]<<endl;

    }
    return 0;
}