답안 #149550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149550 2019-09-01T06:42:36 Z From The Sky(#3630, WhipppedCream, top34051, zoomswk) 포도주 시음 (FXCUP4_wine) C++17
0 / 100
10 ms 1012 KB
#include "bartender.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 35;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

int dat[maxn];

vector<int> BlendWines(int K, std::vector<int> R){
	int n = R.size();
	for(int i = 0; i< n; i++) dat[R[i]] = i;
	vector<int> res(n);
	int fill = 0;
	for(int i = 1, cnt = 1; i<= n; i += 4, cnt++)
	{
		if(i+3> n) break;
		res[dat[i]] = cnt;
		res[dat[i+1]] = cnt;
		res[dat[i+2]] = cnt;
		res[dat[i+3]] = cnt;
		fill = i+3;
	}
	int nxt = fill/4+1;
	for(int x = fill+1; x<= n; x++, nxt++)
	{
		res[dat[x]] = nxt;
	}
	return res;
}
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 2e5+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#include "taster.h"


vector<int> sortFour(int a, int b, int c, int d)
{
	int low1, high1, low2, high2, lowest, middle1, highest, middle2;
	if(Compare(a, b) == -1) low1 = a, high1 = b;
	else low1 = b, high1 = a;
	if(Compare(c, d) == -1) low2 = c, high2 = d;
	else low2 = d, high2 = c;
	if(Compare(low1, low2) == -1) lowest = low1, middle1 = low2;
	else lowest = low2, middle1 = low1;
	if(Compare(high1, high2) == 1) highest = high1, middle2 = high2;
	else highest = high2, middle2 = high1;
	if(Compare(middle1, middle2) == -1) return {lowest, middle1, middle2, highest};
	else return {lowest, middle2, middle1, highest};
}

vector<int> buck[35];

std::vector<int> SortWines(int K, std::vector<int> A)
{
	int n = A.size();
	for(int i = 0; i< n; i++)
	{
		buck[A[i]].pb(i);
	}
	int cur = 0;
	vector<int> ans(n);
	for(int i = 1; i<= 30; i++)
	{
		if(sz(buck[i]) == 0) continue;
		if(sz(buck[i]) == 1)
		{
			ans[buck[i][0]] = ++cur;
			continue;
		}
		vi res = sortFour(buck[i][0], buck[i][1], buck[i][2], buck[i][3]);
		ans[res[0]] = cur+1;
		ans[res[1]] = cur+2;
		ans[res[2]] = cur+3;
		ans[res[3]] = cur+4;
		cur += 4;
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 792 KB Correct
2 Correct 9 ms 788 KB Correct
3 Correct 8 ms 740 KB Correct
4 Correct 9 ms 1012 KB Correct
5 Correct 10 ms 784 KB Correct
6 Correct 9 ms 784 KB Correct
7 Incorrect 8 ms 788 KB Wrong
8 Halted 0 ms 0 KB -