# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97084 | karlopuh | Turnir (COCI17_turnir) | C++14 | 3063 ms | 19768 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;
vector<int> niz;
vector<int> sorted;
vector<int> rj;
int n;
int N;
int main(){
cin>>n;
N=pow(2,n);
for(int i=0;i<N;i++){
int broj;
cin>>broj;
niz.push_back(broj);
sorted.push_back(broj);
rj.push_back(4);
}
sort(sorted.begin(),sorted.end());
for(int i=0;i<N;i++){
if(niz[i]==sorted[sorted.size()-1]){
rj[i]=0;
}
}
for(int b=0;b<N;b++){
for(int i=1;i<=n;i++){
bool moj=false;
int treba=N/(pow(2,i))-1;
for(int j=sorted.size()-1;j>=0;j--){
if(sorted[j]<=niz[b] && moj){
treba--;
}
if(!moj && sorted[j]<=niz[b])moj=true;
}
if(treba<=0){
rj[b]=min(rj[b],i);
}
}
}
for(int i=0;i<N;i++){
cout<<rj[i]<<" ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |