Cod sursa(job #1759287)

Utilizator sulzandreiandrei sulzandrei Data 18 septembrie 2016 19:39:47
Problema Sortare prin comparare Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 2.13 kb
// testarea catorva arbori de aici https://en.wikipedia.org/wiki/List_of_data_structures#Trees
#include <iostream>
#include <fstream>

#include <set>

#include <algorithm>
#include <cmath>
#include <limits>
#include <ctime>
#include <cstdio>
#include <cstdlib>

using namespace std;
std::ifstream in("algsort.in");
std::ofstream out("algsort.out");
/*int maxlevel = 0;
int levelpermis;*/
class RBT
{
public:

    const bool RED = 1,BLACK = 0;
    struct node
    {
        int key;
        unsigned color:1;
        node* left, *right,*parent;
        node(int k,bool c, node* lt, node* rt,node* pt):key{k},color{c},left{lt},right{rt},parent{pt}{};
    };
    node *d[500000];
    //node *d[500000];
    RBT()
    {
        for(int i = 0 ; i<500000; i++)
            d[i] = new node(0,0,nullptr,nullptr,nullptr);
    };//init(); };

};
RBT rbt;
int main()
{

    //BST bst;
    //AVL avl;
    //Treap treap;
    //set<int> um;


    int n,x,op,nr,nr2,j=0;
    in >> n;
    for(int i = 0  ; i< n ; i++)
    {
        //in >> op >> x;
        in >>x;
        /*switch(op)
        {
            case 1:
                treap.insert(x);
                //avl.insert(x);
                //bst.insert(x);
                  //  um.insert(x);
               break;
            case 2:
                treap.erase(x);
                //um.erase(x);
                //bst.erase(x);
                //avl.remove(x);
             break;
            case 3:
                nr = treap.find(x);
                //nr = avl.find(x);
                //nr = bst.find(x);
            //nr2 = (um.find(x)!=um.end())?1:0;
            out<<nr<<'\n';
            //ing>> nr2;
            //j++;
            //if(nr != nr2)
              //  cout<<"linia "<<j<<" "<<nr<<"!="<<nr2<<"elementul "<<x<<'\n';
            break;
        }*/
        //rbt.insert(x);
        //avl.insert(x);
        //treap.insert(x);
        //bst.insert(x);
    }
    for(int i = 0 ; i < n ; i++)
        out<<1<<" ";
    //rbt.showSorted();
    //avl.showSorted();
    //treap.showSorted();
    //bst.showSorted();z
}