# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884398 | gutzzy | Turnir (COCI17_turnir) | C++14 | 405 ms | 21584 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;
int main(){
int n;
cin >> n;
vector<pair<int,int>> nums(pow(2,n));
for(int i=0;i<pow(2,n);i++){
int val;
cin >> val;
nums[i] = {val,i};
}
sort(nums.begin(),nums.end());
vector<int> ans(pow(2,n));
int iguals = 0;
for(int i=pow(2,n);i>=0;i--){
if(i!=pow(2,n)-1 and nums[i+1].first==nums[i].first){
int pos = nums[i].second;
ans[pos] = ans[nums[i+1].second];
}
else{
int num = nums[i].first;
int pos = nums[i].second;
ans[pos] = n - floor(log2(i+1));
}
}
for(auto a:ans) cout << a << " ";
cout << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |