답안 #150884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150884 2019-09-01T09:53:24 Z khsoo01 포도주 시음 (FXCUP4_wine) C++17
65 / 100
11 ms 1032 KB
#include "bartender.h"
using namespace std;

vector<int> BlendWines(int K, vector<int> R) {
	int N = R.size(), L = max(0, N - 27);
	for(int i=0;i<N;i++) R[i]--;
	vector<int> V;
	vector<int> X;
	for(int i=0;i<N;i++) {
		V.push_back(0);
		if(R[i] >= 27) {
			X.push_back(R[i] - 26);
			V[i] = 10;
		}
	}
	for(int i=L+1;i<=9;i++) {
		X.push_back(i);
	}
	for(int i=0;i<N;i++) {
		if(V[i] == 10) continue;
		V[i] = X[R[i] % 9];
	}
	return V;
}
#include "taster.h"
#include<cstdio>
using namespace std;

vector<int> val[15], tens;

void sortA (vector<int> &V) {
	for(int i=0;i<V.size();i++) {
		for(int j=i-1;j>=0;j--) {
			if(Compare(V[j], V[j+1]) == 1) swap(V[j], V[j+1]);
			else break;
		}
	}
}

void sortB (vector<int> &V, vector<int> &T) {
	vector<int> R;
	for(int i=0;i<V.size();i++) R.push_back(-1);
	for(int i=0;i<V.size();i++) {
		int lst = 0;
		for(int j=V.size();j--;) {
			if(R[j] == -1) {
				lst = j;
				break;
			}
		}
		for(int j=0;j<V.size();j++) {
			if(j == lst || (R[j] == -1 && Compare(T[j+1], V[i]) == 1)) {
				R[j] = V[i];
				break;
			}
		}
	}
	swap(R, V);
}

vector<int> SortWines(int K, vector<int> A) {
	int N = A.size(), L = 0;
	vector<int> R;
	for(int i=0;i<N;i++) {
		R.push_back(0);
		if(A[i] == 10) {
			tens.push_back(i);
			L++;
		}
		else {
			val[A[i]].push_back(i);
		}
	}
	vector<int> hds;
	for(int i=1;i<=L;i++) {
		sortA(val[i]);
		hds.push_back(val[i][0]);
	}
	sortA(hds);
	for(int i=0;i<hds.size();i++) {
		int T = A[hds[i]];
		R[tens[i]] = 26 + T;
		for(int j=0;j<val[T].size();j++) {
			R[val[T][j]] = j * 9 + i;
		}
	}
	for(int i=L+1;i<=9;i++) {
		if(i == 1) sortA(val[i]);
		else sortB(val[i], val[1]);
		for(int j=0;j<val[i].size();j++) {
			R[val[i][j]] = j * 9 + i - 1;
		}
	}
	for(int i=0;i<N;i++) R[i]++;
	return R;
}

Compilation message

taster.cpp: In function 'void sortA(std::vector<int>&)':
taster.cpp:8:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++) {
              ~^~~~~~~~~
taster.cpp: In function 'void sortB(std::vector<int>&, std::vector<int>&)':
taster.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++) R.push_back(-1);
              ~^~~~~~~~~
taster.cpp:19:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++) {
              ~^~~~~~~~~
taster.cpp:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<V.size();j++) {
               ~^~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:56:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<hds.size();i++) {
              ~^~~~~~~~~~~
taster.cpp:59:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<val[T].size();j++) {
               ~^~~~~~~~~~~~~~
taster.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<val[i].size();j++) {
               ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 644 KB Correct
2 Correct 8 ms 664 KB Correct
3 Correct 10 ms 896 KB Correct
4 Correct 10 ms 644 KB Correct
5 Correct 10 ms 896 KB Correct
6 Correct 10 ms 676 KB Correct
7 Correct 10 ms 772 KB Correct
8 Correct 9 ms 668 KB Correct
9 Correct 10 ms 780 KB Correct
10 Correct 9 ms 892 KB Correct
11 Correct 8 ms 660 KB Correct
12 Correct 8 ms 804 KB Correct
13 Correct 10 ms 908 KB Correct
14 Correct 10 ms 772 KB Correct
15 Correct 10 ms 780 KB Correct
16 Correct 9 ms 896 KB Correct
17 Correct 10 ms 1028 KB Correct
18 Correct 9 ms 904 KB Correct
19 Correct 10 ms 660 KB Correct
20 Correct 10 ms 668 KB Correct
21 Correct 9 ms 1032 KB Correct
22 Correct 10 ms 896 KB Correct
23 Correct 9 ms 780 KB Correct
24 Correct 10 ms 644 KB Correct
25 Correct 9 ms 780 KB Correct
26 Correct 9 ms 780 KB Correct
27 Correct 8 ms 644 KB Correct
28 Correct 8 ms 644 KB Correct
29 Correct 9 ms 908 KB Correct
30 Correct 10 ms 644 KB Correct
31 Correct 10 ms 780 KB Correct
32 Correct 9 ms 772 KB Correct
33 Correct 9 ms 780 KB Correct
34 Correct 10 ms 644 KB Correct
35 Correct 9 ms 788 KB Correct
36 Correct 9 ms 644 KB Correct
37 Correct 9 ms 772 KB Correct
38 Correct 9 ms 756 KB Correct
39 Correct 8 ms 644 KB Correct
40 Correct 9 ms 908 KB Correct
41 Correct 10 ms 644 KB Correct
42 Correct 9 ms 644 KB Correct
43 Correct 8 ms 772 KB Correct
44 Correct 9 ms 948 KB Correct
45 Correct 8 ms 644 KB Correct
46 Correct 9 ms 772 KB Correct
47 Correct 10 ms 780 KB Correct
48 Correct 10 ms 644 KB Correct
49 Correct 9 ms 644 KB Correct
50 Correct 9 ms 780 KB Correct
51 Correct 9 ms 644 KB Correct
52 Correct 10 ms 908 KB Correct
53 Correct 8 ms 780 KB Correct
54 Correct 9 ms 644 KB Correct
55 Correct 10 ms 644 KB Correct
56 Correct 10 ms 644 KB Correct
57 Correct 9 ms 772 KB Correct
58 Correct 10 ms 980 KB Correct
59 Correct 9 ms 756 KB Correct
60 Correct 8 ms 644 KB Correct
61 Correct 10 ms 772 KB Correct
62 Correct 9 ms 908 KB Correct
63 Correct 9 ms 644 KB Correct
64 Correct 9 ms 772 KB Correct
65 Correct 9 ms 772 KB Correct
66 Correct 9 ms 772 KB Correct
67 Correct 9 ms 1024 KB Correct
68 Correct 9 ms 780 KB Correct
69 Correct 9 ms 780 KB Correct
70 Correct 8 ms 644 KB Correct
71 Correct 8 ms 780 KB Correct
72 Correct 8 ms 1028 KB Correct
73 Correct 8 ms 772 KB Correct
74 Correct 9 ms 644 KB Correct
75 Correct 10 ms 772 KB Correct
76 Correct 9 ms 644 KB Correct
77 Correct 10 ms 920 KB Correct
78 Correct 9 ms 644 KB Correct
79 Correct 8 ms 644 KB Correct
80 Partially correct 9 ms 644 KB Wrong
81 Partially correct 9 ms 896 KB Wrong
82 Partially correct 9 ms 772 KB Wrong
83 Partially correct 9 ms 644 KB Wrong
84 Partially correct 9 ms 780 KB Wrong
85 Partially correct 10 ms 908 KB Wrong
86 Partially correct 10 ms 756 KB Wrong
87 Partially correct 10 ms 908 KB Wrong
88 Correct 9 ms 772 KB Correct
89 Correct 8 ms 772 KB Correct
90 Correct 10 ms 780 KB Correct
91 Partially correct 9 ms 644 KB Wrong
92 Partially correct 9 ms 772 KB Wrong
93 Partially correct 9 ms 780 KB Wrong
94 Partially correct 8 ms 644 KB Wrong
95 Partially correct 9 ms 772 KB Wrong
96 Partially correct 9 ms 644 KB Wrong
97 Partially correct 10 ms 780 KB Wrong
98 Partially correct 8 ms 644 KB Wrong
99 Partially correct 10 ms 772 KB Wrong
100 Partially correct 8 ms 644 KB Wrong
101 Partially correct 9 ms 644 KB Wrong
102 Partially correct 9 ms 708 KB Wrong
103 Correct 9 ms 644 KB Correct
104 Correct 10 ms 772 KB Correct
105 Correct 8 ms 668 KB Correct
106 Partially correct 8 ms 644 KB Wrong
107 Partially correct 10 ms 908 KB Wrong
108 Partially correct 10 ms 780 KB Wrong
109 Partially correct 8 ms 644 KB Wrong
110 Partially correct 9 ms 644 KB Wrong
111 Partially correct 8 ms 644 KB Wrong
112 Partially correct 8 ms 772 KB Wrong
113 Partially correct 8 ms 908 KB Wrong
114 Partially correct 9 ms 772 KB Wrong
115 Partially correct 10 ms 644 KB Wrong
116 Partially correct 10 ms 644 KB Wrong
117 Partially correct 8 ms 644 KB Wrong
118 Partially correct 9 ms 644 KB Wrong
119 Partially correct 10 ms 676 KB Wrong
120 Partially correct 9 ms 908 KB Wrong