#include"bartender.h"
#include<algorithm>
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf=1e18;
vector<int>BlendWines(int K,vector<int>R)
{
int n=R.size();
vector<pi>v;
int i;
for(i=0;i<n;i++)
v.eb(R[i],i);
sort(all(v));
vector<int>ret(n);
if(n<11)
{
for(i=0;i<n;i++)
ret[v[i].se]=i+1;
}
else
{
ret[v[0].se]=10;
ret[v[n-1].se]=10;
ret[v[1].se]=9;
ret[v[n-2].se]=9;
ret[v[2].se]=8;
ret[v[n-3].se]=8;
ret[v[3].se]=7;
ret[v[n-4].se]=7;
ret[v[4].se]=6;
ret[v[n-5].se]=6;
for(i=0;i<5;i++)
for(int j=0;j<4&&i*4+j+10<n;j++)
ret[v[5+i*4+j].se]=i+1;
}
return ret;
}
#include"taster.h"
#include<algorithm>
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf=1e18;
inline bool query(int x,int y)
{
return Compare(x,y)==1;
}
inline void sort2(vector<int>&A)
{
if(query(A[0],A[1]))
swap(A[0],A[1]);
return;
}
inline void sort3(vector<int>&A)
{
if(query(A[0],A[1]))
swap(A[0],A[1]);
if(query(A[0],A[2]))
swap(A[0],A[2]);
if(query(A[1],A[2]))
swap(A[1],A[2]);
return;
}
inline void sort4(vector<int>&A)
{
if(query(A[0],A[1]))
swap(A[0],A[1]);
if(query(A[2],A[3]))
swap(A[2],A[3]);
if(query(A[0],A[2]))
{
swap(A[0],A[2]);
swap(A[1],A[3]);
}
if(query(A[1],A[2]))
swap(A[1],A[2]);
if(query(A[2],A[3]))
swap(A[2],A[3]);
return;
}
inline void sort(vector<int>&A)
{
if(A.size()==2)
sort2(A);
if(A.size()==3)
sort3(A);
if(A.size()==4)
sort4(A);
return;
}
vector<int>SortWines(int K,vector<int>A)
{
int n=A.size();
vector<int>ret,ans;
vector<int>v[10];
int i;
for(i=0;i<n;i++)
v[A[i]-1].eb(i);
if(n<11)
{
for(i=0;i<n;i++)
ret.eb(v[i][0]);
}
else
{
if(query(v[9][0],v[0][0]))
swap(v[9][0],v[9][1]);
if(query(v[8][0],v[0][0]))
swap(v[8][0],v[8][1]);
if(query(v[7][0],v[0][0]))
swap(v[7][0],v[7][1]);
if(query(v[6][0],v[0][0]))
swap(v[6][0],v[6][1]);
if(query(v[5][0],v[0][0]))
swap(v[5][0],v[5][1]);
for(i=0;i<5;i++)
sort(v[i]);
for(i=10;i-->5;)
ret.eb(v[i][0]);
for(i=0;i<5;i++)
for(int t:v[i])
ret.eb(t);
for(i=5;i<10;i++)
ret.eb(v[i][1]);
}
ans.resize(n);
for(i=0;i<n;i++)
ans[ret[i]]=i+1;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
780 KB |
Correct |
2 |
Correct |
8 ms |
780 KB |
Correct |
3 |
Correct |
9 ms |
644 KB |
Correct |
4 |
Correct |
9 ms |
900 KB |
Correct |
5 |
Correct |
9 ms |
644 KB |
Correct |
6 |
Correct |
8 ms |
780 KB |
Correct |
7 |
Correct |
9 ms |
780 KB |
Correct |
8 |
Correct |
9 ms |
772 KB |
Correct |
9 |
Correct |
9 ms |
780 KB |
Correct |
10 |
Correct |
10 ms |
780 KB |
Correct |
11 |
Correct |
10 ms |
644 KB |
Correct |
12 |
Correct |
10 ms |
644 KB |
Correct |
13 |
Correct |
9 ms |
772 KB |
Correct |
14 |
Correct |
9 ms |
644 KB |
Correct |
15 |
Correct |
9 ms |
772 KB |
Correct |
16 |
Correct |
10 ms |
772 KB |
Correct |
17 |
Correct |
9 ms |
940 KB |
Correct |
18 |
Correct |
8 ms |
644 KB |
Correct |
19 |
Correct |
9 ms |
780 KB |
Correct |
20 |
Correct |
10 ms |
644 KB |
Correct |
21 |
Correct |
10 ms |
780 KB |
Correct |
22 |
Correct |
9 ms |
644 KB |
Correct |
23 |
Correct |
10 ms |
692 KB |
Correct |
24 |
Correct |
9 ms |
644 KB |
Correct |
25 |
Correct |
8 ms |
772 KB |
Correct |
26 |
Correct |
10 ms |
780 KB |
Correct |
27 |
Correct |
10 ms |
772 KB |
Correct |
28 |
Correct |
9 ms |
780 KB |
Correct |
29 |
Correct |
9 ms |
780 KB |
Correct |
30 |
Correct |
9 ms |
772 KB |
Correct |
31 |
Correct |
9 ms |
772 KB |
Correct |
32 |
Correct |
11 ms |
772 KB |
Correct |
33 |
Correct |
9 ms |
756 KB |
Correct |
34 |
Correct |
11 ms |
644 KB |
Correct |
35 |
Correct |
9 ms |
644 KB |
Correct |
36 |
Correct |
10 ms |
772 KB |
Correct |
37 |
Correct |
9 ms |
644 KB |
Correct |
38 |
Correct |
10 ms |
772 KB |
Correct |
39 |
Correct |
10 ms |
796 KB |
Correct |
40 |
Correct |
9 ms |
908 KB |
Correct |
41 |
Correct |
9 ms |
668 KB |
Correct |
42 |
Correct |
9 ms |
644 KB |
Correct |
43 |
Correct |
10 ms |
908 KB |
Correct |
44 |
Correct |
8 ms |
644 KB |
Correct |
45 |
Correct |
8 ms |
644 KB |
Correct |
46 |
Correct |
9 ms |
908 KB |
Correct |
47 |
Correct |
9 ms |
644 KB |
Correct |
48 |
Correct |
9 ms |
896 KB |
Correct |
49 |
Correct |
8 ms |
644 KB |
Correct |
50 |
Correct |
10 ms |
1024 KB |
Correct |
51 |
Correct |
9 ms |
780 KB |
Correct |
52 |
Correct |
9 ms |
780 KB |
Correct |
53 |
Correct |
8 ms |
644 KB |
Correct |
54 |
Correct |
9 ms |
872 KB |
Correct |
55 |
Correct |
8 ms |
644 KB |
Correct |
56 |
Correct |
9 ms |
644 KB |
Correct |
57 |
Correct |
9 ms |
644 KB |
Correct |
58 |
Correct |
8 ms |
644 KB |
Correct |
59 |
Correct |
10 ms |
644 KB |
Correct |
60 |
Correct |
10 ms |
644 KB |
Correct |
61 |
Correct |
9 ms |
756 KB |
Correct |
62 |
Correct |
10 ms |
772 KB |
Correct |
63 |
Correct |
10 ms |
908 KB |
Correct |
64 |
Correct |
10 ms |
644 KB |
Correct |
65 |
Correct |
8 ms |
644 KB |
Correct |
66 |
Correct |
9 ms |
908 KB |
Correct |
67 |
Correct |
8 ms |
780 KB |
Correct |
68 |
Correct |
8 ms |
644 KB |
Correct |
69 |
Correct |
9 ms |
1036 KB |
Correct |
70 |
Correct |
10 ms |
644 KB |
Correct |
71 |
Correct |
9 ms |
644 KB |
Correct |
72 |
Correct |
9 ms |
644 KB |
Correct |
73 |
Partially correct |
8 ms |
644 KB |
Wrong |
74 |
Partially correct |
8 ms |
644 KB |
Wrong |
75 |
Partially correct |
10 ms |
780 KB |
Wrong |
76 |
Correct |
10 ms |
644 KB |
Correct |
77 |
Correct |
10 ms |
772 KB |
Correct |
78 |
Correct |
9 ms |
772 KB |
Correct |
79 |
Partially correct |
9 ms |
644 KB |
Wrong |
80 |
Partially correct |
8 ms |
756 KB |
Wrong |
81 |
Partially correct |
9 ms |
772 KB |
Wrong |
82 |
Partially correct |
10 ms |
780 KB |
Wrong |
83 |
Partially correct |
10 ms |
772 KB |
Wrong |
84 |
Partially correct |
9 ms |
772 KB |
Wrong |
85 |
Partially correct |
9 ms |
772 KB |
Wrong |
86 |
Partially correct |
9 ms |
772 KB |
Wrong |
87 |
Partially correct |
8 ms |
908 KB |
Wrong |
88 |
Correct |
10 ms |
780 KB |
Correct |
89 |
Correct |
8 ms |
644 KB |
Correct |
90 |
Correct |
9 ms |
908 KB |
Correct |
91 |
Partially correct |
8 ms |
644 KB |
Wrong |
92 |
Partially correct |
10 ms |
644 KB |
Wrong |
93 |
Partially correct |
9 ms |
772 KB |
Wrong |
94 |
Partially correct |
9 ms |
732 KB |
Wrong |
95 |
Partially correct |
10 ms |
1032 KB |
Wrong |
96 |
Partially correct |
10 ms |
900 KB |
Wrong |
97 |
Partially correct |
10 ms |
780 KB |
Wrong |
98 |
Partially correct |
10 ms |
644 KB |
Wrong |
99 |
Partially correct |
9 ms |
756 KB |
Wrong |
100 |
Partially correct |
10 ms |
780 KB |
Wrong |
101 |
Partially correct |
10 ms |
644 KB |
Wrong |
102 |
Partially correct |
10 ms |
772 KB |
Wrong |
103 |
Correct |
10 ms |
820 KB |
Correct |
104 |
Correct |
10 ms |
860 KB |
Correct |
105 |
Correct |
9 ms |
908 KB |
Correct |
106 |
Partially correct |
8 ms |
644 KB |
Wrong |
107 |
Partially correct |
9 ms |
780 KB |
Wrong |
108 |
Partially correct |
8 ms |
780 KB |
Wrong |
109 |
Partially correct |
10 ms |
772 KB |
Wrong |
110 |
Partially correct |
10 ms |
780 KB |
Wrong |
111 |
Partially correct |
9 ms |
644 KB |
Wrong |
112 |
Partially correct |
9 ms |
644 KB |
Wrong |
113 |
Partially correct |
9 ms |
644 KB |
Wrong |
114 |
Partially correct |
9 ms |
644 KB |
Wrong |
115 |
Partially correct |
10 ms |
864 KB |
Wrong |
116 |
Partially correct |
9 ms |
644 KB |
Wrong |
117 |
Partially correct |
8 ms |
644 KB |
Wrong |
118 |
Partially correct |
9 ms |
780 KB |
Wrong |
119 |
Partially correct |
9 ms |
908 KB |
Wrong |
120 |
Partially correct |
8 ms |
644 KB |
Wrong |