# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97085 | karlopuh | Turnir (COCI17_turnir) | C++14 | 3052 ms | 12724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++){
if(rj[b]!=4)continue;
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){
for(int z=0;z<N;z++){
if(niz[z]==niz[b]){
rj[z]=min(rj[b],i);
}
}
rj[b]=min(rj[b],i);
break;
}
}
}
}
for(int i=0;i<N;i++){
cout<<rj[i]<<" ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |