답안 #150863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150863 2019-09-01T08:59:58 Z ----MIT합격선----(#3601, maruii, Diuven, andy627) 포도주 시음 (FXCUP4_wine) C++17
컴파일 오류
0 ms 0 KB
#include "bartender.h"

std::vector<int> BlendWines(int K, std::vector<int> R){
	int N = R.size();
	std::vector<int> A(N);
	for(int i=0; i<N; i++) A[i] = (R[i]-1)/10+1;
	return A;
}
#include "taster.h"
using namespace std;

bool ch(int a, int b){ return Compare(a,b)>0; }

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

	vector<int> R(n), V[11];

	for(int i=0; i<n; i++){
		V[A[i]].push_back(i);
	}
	for(int i=1; i<=10; i++){
		if(V[i].empty()) continue;
		int m = V[i].size();
		if(m==1) R[V[i][0]] = (i-1)*3+1;
		if(m==2){
			R[V[i][0]] = (i-1)*3 + 1;
			R[V[i][1]] = (i-1)*3 + 2;
			if(ch(V[i][0], V[i][1])) swap(R[V[i][0]], R[V[i][1]]);
		}
		if(m==3){
			R[V[i][0]] = (i-1)*3 + 1;
			R[V[i][1]] = (i-1)*3 + 2;
			R[V[i][2]] = (i-1)*3 + 3;
			if(ch(V[i][0], V[i][1])) swap(R[V[i][0]], R[V[i][1]]);
			if(ch(V[i][1], V[i][2])) swap(R[V[i][1]], R[V[i][2]]);
			if(ch(V[i][0], V[i][1])) swap(R[V[i][0]], R[V[i][1]]);
		}
	}
	return R;

	for(int i=0; i<n; i++)
		if(A[i]==1) on.push_back(i);
	
	int m = on.size();

	if(on.size()==3U){
		if(ch(on[0], on[1])) swap(on[0], on[1]);
		if(ch(on[1], on[2])) swap(on[1], on[2]);
		if(ch(on[0], on[1])) swap(on[0], on[1]);
	}
	if(on.size()==2U){
		if(ch(on[0], on[1])) swap(on[0], on[1]);
	}
	if(on.size()==1U){
	}
	for(int k=0; k<m; k++) R[on[k]] = 10*k+1;
	
	for(int i=0; i<n; i++){
		if(A[i]==1) continue;
		if(m==1) R[i] = A[i];

		if(m==2){
			if(ch(on[1], i)) R[i] = A[i];
			else R[i] = 10+A[i];
		}
		if(m==3){
			if(ch(on[1], i)) R[i] = A[i];
			else if(ch(on[2], i)) R[i] = 10+A[i];
			else R[i] = 20+A[i];
		}
	}

	return R;
}

Compilation message

taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:35:15: error: 'on' was not declared in this scope
   if(A[i]==1) on.push_back(i);
               ^~
taster.cpp:35:15: note: suggested alternative: 'n'
   if(A[i]==1) on.push_back(i);
               ^~
               n
taster.cpp:37:10: error: 'on' was not declared in this scope
  int m = on.size();
          ^~
taster.cpp:37:10: note: suggested alternative: 'n'
  int m = on.size();
          ^~
          n