제출 #149959

#제출 시각아이디문제언어결과실행 시간메모리
149959서울대학교 연구공원 944동 삼성전자서울대연구소 (#200)Wine Tasting (FXCUP4_wine)C++17
18 / 100
15 ms1064 KiB
#include "bartender.h"

#include<bits/stdc++.h>
using namespace std;

static vector<int> shuf;

static void Init(int N)
{
	mt19937_64 rng(573);
	for(int i=0; i<N; ++i)
		shuf.push_back(rng()%(N-i));
}

static void Shuffle(vector<int>& R)
{
	int N = R.size();
	Init(N);
	for(int i=0; i<N; ++i)
		swap(R[N-1-i],R[shuf[i]]);
}

static void DeShuffle(vector<int>& R)
{
	int N = R.size();
	Init(N);
	for(int i=N-1; i>=0; --i)
		swap(R[N-1-i],R[shuf[i]]);
}

std::vector<int> BlendWines(int K, std::vector<int> R){
	int N = R.size();
	Shuffle(R);
	vector<int> ret(N);
	int cur = 1;
	for(int step=1;;++step)
	{
		for(int i=0; i<N; ++i)
		{
			if(cur == R[i])
			{
				ret[i] = step;
				++cur;
			}
		}
		if(cur==N+1) break;
	}
	return ret;
}
#include "taster.h"


#include<bits/stdc++.h>
using namespace std;

static vector<int> shuf;

static void Init(int N)
{
	mt19937_64 rng(573);
	for(int i=0; i<N; ++i)
		shuf.push_back(rng()%(N-i));
}

static void Shuffle(vector<int>& R)
{
	int N = R.size();
	Init(N);
	for(int i=0; i<N; ++i)
		swap(R[N-1-i],R[shuf[i]]);
}

static void DeShuffle(vector<int>& R)
{
	int N = R.size();
	Init(N);
	for(int i=N-1; i>=0; --i)
		swap(R[N-1-i],R[shuf[i]]);
}

std::vector<int> SortWines(int K, std::vector<int> A) {
	int N = A.size();

	vector<int> R(N);

	int ans = 1;

	for(int i=0; i<K; ++i)
	{
		for(int j=0; j<N; ++j)
			if(A[j] == i)
			{
				R[j] = ans++;
			}
	}
	DeShuffle(R);
	return R;
}

컴파일 시 표준 에러 (stderr) 메시지

bartender.cpp:23:13: warning: 'void DeShuffle(std::vector<int>&)' defined but not used [-Wunused-function]
 static void DeShuffle(vector<int>& R)
             ^~~~~~~~~

taster.cpp:16:13: warning: 'void Shuffle(std::vector<int>&)' defined but not used [-Wunused-function]
 static void Shuffle(vector<int>& R)
             ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...