Submission #247211

# Submission time Handle Problem Language Result Execution time Memory
247211 2020-07-11T08:01:25 Z oolimry Wine Tasting (FXCUP4_wine) C++17
0 / 100
10 ms 1012 KB
#include "bartender.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> BlendWines(int K, vector<int> R){
	if(K < 11) assert(false);
	
	vector<int> ans;
	for(int x : R){
		int grp = ((x-1) / 6);
		grp++;
		
		if((x-1) % 6 == 0 || (x-1) % 6 == 5){
			ans.push_back(11-grp);
		}
		else ans.push_back(grp);
	}
	
	return ans;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;

int n;
int cmp(int a, int b){
	//cout << "Q: " << a << " " << b << "\n";
	if(a >= n && b >= n){
		if(a < b) return -1;
		else return 1;
	}
	if(a >= n) return 1;
	if(b >= n) return -1;
	int res=  Compare(a,b);
	//cout << res << "\n";
	return res;
}

vector<int> SortWines(int K, vector<int> A) {
	
	n = A.size();
	
	while(A.size() < 30){
		int x = A.size()+1;
		int grp = ((x-1) / 6);
		grp++;
		
		if((x-1) % 6 == 0 || (x-1) % 6 == 5){
			A.push_back(11-grp);
		}
		else A.push_back(grp);
	}
	
	//for(int i : A) cout << i << " ";
	
	vector<int> res;
	for(int i = 0;i < 30;i++) res.push_back(0);
	
	for(int f = 1;f <= 5;f++){
		vector<int> v;
		for(int i = 0;i < 30;i++){
			if(A[i] == f) v.push_back(i);
		}
		
		//cout << v[0] << " " << v[1] << " " << v[2] <<  " " << v[3] << "\n";
		
		if(cmp(v[0], v[1]) == 1) swap(v[0], v[1]);
		if(cmp(v[2], v[3]) == 1) swap(v[2], v[3]);
		
		
		
		if(cmp(v[0], v[2]) == 1) swap(v[0], v[2]);
		if(cmp(v[1], v[3]) == 1) swap(v[1], v[3]);
		if(cmp(v[1], v[2]) == 1) swap(v[1], v[2]);
		
		//cout << v[0] << " " << v[1] << " " << v[2] <<  " " << v[3] << "\n";
		
		for(int i = 0;i < 4;i++){
			res[v[i]] = (f-1)*6 + i + 2;
		}
		
			
		int small = (f-1)*6 + 1;
		int big = (f-1)*6 + 6;
		
		vector<int> o;
		for(int i = 0;i < 30;i++){
			if(A[i] == 11-f) o.push_back(i);
		}
		
		if(cmp(o[0], v[0]) == 1) swap(o[0], o[1]);
		res[o[0]] = small;
		res[o[1]] = big;
	}
	
	while((int) res.size() > n) res.pop_back();
	for(int i : res) cout << i << " ";
	
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1012 KB Wrong
2 Halted 0 ms 0 KB -