Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
3
Indexable
Never
#include <iostream>
#define MAX_N 1000001

using namespace std;

//Tao Node
class Soldier {
public:
    int id, team;
    Soldier* next; 
    Soldier* prev;
    Soldier() {
        id = -1;
        team = -1;
        next = NULL;
        prev = NULL;
    }
};

void connect(Soldier* a, Soldier* b)
{
    a->next = b;
    b->prev = a;
}

//Tao linked list
class List {
public:
    Soldier* head;
    Soldier* tail;
    List() {
        connect(head, tail);
    }

    //Ham xoa node
    void earse(Soldier* soldier) {
        connect(soldier->prev, soldier->next);
        delete (soldier);
    }

    //Ham them node vao cuoi
    void insert(Soldier* soldier) {
        connect(soldier, tail);
        connect(tail->prev, soldier);
    }

    //Ham kiem tra xem List co rong khong
    bool isEmpty() {
        return head->next == tail;
    }

    //Ham gop list khac vao trong list hien tai
    void merge(List* l2) {
        Soldier* h2 = l2->head->next;
        Soldier* t2 = l2->tail->prev;
        Soldier* t1 = tail->prev;

        connect(t1, h2);
        connect(t2, tail);
        connect(l2->head, l2->tail);
    }
};

List ll[6][6];
Soldier soldier[MAX_N];

void init()
{
   
}

void hire(int mID, int mTeam, int mScore)
{

}

void fire(int mID)
{

}

void updateSoldier(int mID, int mScore)
{

}

void updateTeam(int mTeam, int mChangeScore)
{

}

int bestSoldier(int mTeam)
{
    return 0;
}