# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771353 | BidoTeima | San (COCI17_san) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<pair<ll,int>>vals;
const int N = 1 << 20;
vector<int> st[4 * N];
void build(int l, int r, int node){
if(l == r){
st[node].push_back(vals[l].second);
return;
}
int mid = (l + r) >> 1;
build(l, mid, 2 * node + 1);
build(mid + 1, r, 2 * node + 2);
int l = 0, r = 0;
while((int)st[node].size()<r-l+1){
if(l == (int)st[2 * node + 1].size()){
st[node].push_back(st[2 * node + 2][r]);
++r;
continue;
}
if(r == (int)st[2 * node + 2].size()){
st[node].push_back(st[2 * node + 1][r]);
++l;
continue;
}
if(st[2 * node + 1][l] < st[2 * node + 2][r]){
st[node].push_back(st[2 * node + 1][l]);
++l;
}else{