# Cod sursa(job #2484315)

Utilizator Data 30 octombrie 2019 22:26:27 Secv8 0 cpp-64 done Arhiva de probleme 4.27 kb
#include <fstream>
#include <stdlib.h>
#include <ctime>
#define INF 2000000000
using namespace std;

ifstream fin ("secv8.in");
ofstream fout ("secv8.out");
struct treap{
int val;
int priority;
int nr;
int lazy;
treap *left;
treap *right;
treap (int val, int priority, int nr, int lazy, treap *left, treap *right){
this->val = val;
this->priority = priority;
this->nr = nr;
this->lazy = lazy;
this->left = left;
this->right = right;
}};
int get_random (){
return 1LL*rand()*rand()%(INF-1)+1;
}
else {
/// acum lazy ul
/// acum trebuie sa interschimb fiii
}}
}
pair <treap*,treap*> split (treap *rad, int poz){
pair <treap*, treap*> ans;
return make_pair(nil,nil);
if (rad->left->nr + 1 > poz){ /// o sa ma duc in stanga
} else {
}
return ans;
}
/// si treapul rezultat e tot fiul drept a lui rad1
} else {
}
return nil;
}
treap* _insert (treap *rad, int poz, int val){
pair <treap*,treap*> aux = split (rad,poz-1);
}
treap* access (treap *rad, int nr){
pair <treap*,treap*> aux2 = split (rad,nr);
pair <treap*,treap*> aux1 = split (aux2.first,nr-1);
fout<<aux1.second->val<<"\n";
aux2.first = join (aux1.first,aux1.second);
}
treap* _delete (treap *rad, int x, int y){
/// dau split de doua ori si unesc cele doua bucati
pair <treap*, treap*> aux2 = split (rad,y);
pair <treap*, treap*> aux1 = split (aux2.first,x-1);
/// acum trb sa le dau join
}

treap* _reverse (treap *rad, int x, int y){
/// trb sa aflu bucata din mijloc
pair <treap*, treap*> aux2 = split (rad,y);
pair <treap*, treap*> aux1 = split (aux2.first,x-1);
/// trb sa marchez in lazy
aux1.second->lazy = 1;
/// acum trebuie sa le unesc la loc
aux2.first = join (aux1.first, aux1.second);
}
return;
return;
}
int main (){

srand(time(0));
rad = nil = new treap (0,0,0,0,NULL,NULL);

int t,x,y,poz,ok;
fin>>t>>ok;
for (;t--;){
char op; fin>>op;
if (op == 'I'){
fin>>poz>>x;
continue;
}
if (op == 'A'){
fin>>x;
continue;
}
if (op == 'R'){
fin>>x>>y;