Submission #97085

# Submission time Handle Problem Language Result Execution time Memory
97085 2019-02-13T18:55:53 Z karlopuh Turnir (COCI17_turnir) C++14
30 / 100
3000 ms 12724 KB
#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
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Incorrect 147 ms 604 KB Output isn't correct
5 Execution timed out 3006 ms 896 KB Time limit exceeded
6 Execution timed out 3039 ms 1276 KB Time limit exceeded
7 Execution timed out 3037 ms 2024 KB Time limit exceeded
8 Execution timed out 3052 ms 3520 KB Time limit exceeded
9 Execution timed out 3036 ms 6668 KB Time limit exceeded
10 Execution timed out 3031 ms 12724 KB Time limit exceeded