Pagini recente » Cod sursa (job #2500293) | Cod sursa (job #531126) | Cod sursa (job #2126674) | Cod sursa (job #2721536) | Cod sursa (job #2209658)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
struct thing{
float code;
int idx;
bool operator<(const thing &obj)const{
return code < obj.code;
}
};
typedef tree<thing, null_type, less<thing>, rb_tree_tag, tree_order_statistics_node_update> Set;
int n;
Set s;
thing mkt(int idx, float code)
{
thing aux;
aux.code = code;
aux.idx = idx;
return aux;
}
int main()
{
ifstream fin ("schi.in");
ofstream fout ("schi.out");
int x;
fin >> n >> x;
srand(time(NULL));
//float r3 = 2 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(4.3-2)));
s.insert(mkt(1, static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(1000000)))));
for (int i = 2; i <= n; ++i){
fin >> x;
if(x == 1){
float a1 = 0;
float a2 = (*s.find_by_order(x-1)).code;
s.insert(mkt(i, a1 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(a2-a1)))));
}else if (x == i){
float a1 = (*s.find_by_order(x-2)).code;
float a2 = 1000000;
s.insert(mkt(i, a1 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(a2-a1)))));
}else{
float a1 = (*s.find_by_order(x-2)).code;
float a2 = (*s.find_by_order(x-1)).code;
s.insert(mkt(i, a1 + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(a2-a1)))));
}
}
int d = 1;
for (Set::iterator it = s.begin(); it != s.end(); ++it)
fout << it->idx << "\n";
return 0;
}