답안 #149471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149471 2019-09-01T06:33:45 Z Powered By Zigui(#3580, aaaa, evenharder, best_sheild97) 포도주 시음 (FXCUP4_wine) C++17
49 / 100
11 ms 1040 KB
#include "bartender.h"

using namespace std;

std::vector<int> BlendWines(int K, std::vector<int> R){
    int x[30] = {1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,8,9,10,11,12};
    vector<int> A(R.size());
    int n = R.size();
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(R[j] == i+1)
            {
                A[j] = x[i];
            }
        }
    }
	return A;
}
#include "taster.h"

#include <vector>
#include <algorithm>
using namespace std;
std::vector<int> v[31];
void SortSomeWines(std::vector<int>& p)
{
    if(p.size() <= 1) return;
    else if(p.size() == 2)
    {
        if(Compare(p[0], p[1]) == 1) swap(p[0], p[1]);
    }
    else if(p.size() == 3)
    {
        int a = p[0], b = p[1], c = p[2];
        if(Compare(a, b) == 1)
        {
            swap(a, b);
        }
        if(Compare(c, a) == 1)
        {
            if(Compare(b, c) == 1)
            {
                swap(b, c);
            }
            p = vector<int>({a, b, c});
        }
        else
        {
            p = vector<int>({c, a, b});
        }
    }
    else
    {
        int l1, l2, h1, h2, ll, hh, m1, m2;
        if(Compare(p[0], p[1]) == 1) 
            l1 = p[0], h1 = p[1];
        else l1 = p[1], h1 = p[0];
        if(Compare(p[2], p[3]) == 1) 
            l2 = p[2], h2 = p[3];
        else l2 = p[3], h2 = p[2];
        
        if(Compare(l1, l2) == 1)
            ll = l1, m1 = l2;
        else ll = l2, m1 = l1;
        if(Compare(h1, h2) == -1)
            hh = h1, m2 = h2;
        else hh = h2, m2 = h1;
        if(Compare(m1, m2) == 1)
            p = vector<int>({hh, m2, m1, ll});
        else p = vector<int>({hh, m1, m2, ll});
    }
}
std::vector<int> SortWines(int K, std::vector<int> A) {
	int N = A.size();

    for(int i=0;i<A.size();i++)
    {
        v[A[i]].push_back(i);
    }

    for(int i=1;i<=30;i++)
    {
        SortSomeWines(v[i]);
    }
    vector<int> ans, rans(A.size());
    for(int i=1;i<=30;i++)
    {
        for(int x : v[i])
        {
            ans.push_back(x);
        }
    }
    for(int i=0;i<A.size();i++)
    {    
        rans[ans[i]] = i+1;
    }
	return rans;
}

Compilation message

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