#include <bits/stdc++.h>
#include "bartender.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const int val[]={1,10,1,10,1,10,2,9,2,9,2,9,3,8,3,8,3,8,4,7,4,7,4,7,5,6,5,6,5,6};
std::vector<int> BlendWines(int k, std::vector<int> r){
if (k<11) return r;
int n=sz(r);
vector<int> v;
rep(x,0,n){
v.push_back(x);
}
sort(all(v),[r](int i,int j){
return r[i]<r[j];
});
vector<int> ans(n);
rep(x,0,n){
ans[x]=val[r[x]-1];
}
//rep(x,0,n) cout<<ans[x]<<" ";cout<<endl;
return ans;
}
#include <bits/stdc++.h>
#include "taster.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const int val[]={1,10,2,9,3,8,4,7,5,6};
int temp[6];
std::vector<int> SortWines(int k, std::vector<int> a) {
if (k<11) return a;
int n=sz(a);
vector<int> ans;
rep(pos,0,5){
vector<int> small;
vector<int> big;
rep(x,0,n){
if (a[x]==val[pos*2]) small.push_back(x);
if (a[x]==val[pos*2+1]) big.push_back(x);
}
memset(temp,-1,sizeof(temp));
for (auto &it:small){
if (temp[0]==-1){
temp[0]=it;
}
else if (temp[2]==-1){
temp[2]=it;
if (Compare(temp[0],temp[2])==1) swap(temp[0],temp[2]);
}
else{
temp[4]=it;
if (Compare(temp[2],temp[4])==1) swap(temp[2],temp[4]);
if (Compare(temp[0],temp[2])==1) swap(temp[0],temp[2]);
}
}
if (sz(big)==1) temp[3]=temp[5]=-2;
if (sz(big)==2) temp[5]=-2;
for (auto &it:big){ //if else spam is my passion
if (temp[1]==-1 && temp[3]==-1 && temp[5]==-1){
if (Compare(it,temp[2])==-1) temp[1]=it;
else if (Compare(it,temp[4])==-1) temp[3]=it;
else temp[5]=it;
}
else if (temp[1]==-1 && temp[3]==-1){
if (Compare(it,temp[2])==-1) temp[1]=it;
else temp[3]=it;
}
else if (temp[1]==-1 && temp[5]==-1){
if (Compare(it,temp[2])==-1) temp[1]=it;
else temp[5]=it;
}
else if (temp[3]==-1 && temp[5]==-1){
if (Compare(it,temp[4])==-1) temp[3]=it;
else temp[5]=it;
}
else if (temp[1]==-1){
temp[1]=it;
}
else if (temp[3]==-1){
temp[3]=it;
}
else{
temp[5]=it;
}
}
rep(x,0,6) if (temp[x]!=-1) ans.push_back(temp[x]);
}
//rep(x,0,n) cout<<ans[x]<<" ";cout<<endl;
vector<int> perm(n);
rep(x,0,n) perm[ans[x]]=x+1;
//rep(x,0,n) cout<<perm[x]<<" ";cout<<endl;
return perm;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
884 KB |
Correct |
2 |
Correct |
8 ms |
792 KB |
Correct |
3 |
Correct |
9 ms |
780 KB |
Correct |
4 |
Correct |
9 ms |
780 KB |
Correct |
5 |
Correct |
8 ms |
788 KB |
Correct |
6 |
Correct |
8 ms |
772 KB |
Correct |
7 |
Correct |
9 ms |
780 KB |
Correct |
8 |
Correct |
10 ms |
780 KB |
Correct |
9 |
Correct |
9 ms |
644 KB |
Correct |
10 |
Correct |
9 ms |
788 KB |
Correct |
11 |
Correct |
9 ms |
664 KB |
Correct |
12 |
Correct |
8 ms |
788 KB |
Correct |
13 |
Correct |
10 ms |
644 KB |
Correct |
14 |
Correct |
11 ms |
792 KB |
Correct |
15 |
Correct |
8 ms |
780 KB |
Correct |
16 |
Correct |
9 ms |
784 KB |
Correct |
17 |
Correct |
8 ms |
788 KB |
Correct |
18 |
Correct |
9 ms |
1012 KB |
Correct |
19 |
Correct |
10 ms |
792 KB |
Correct |
20 |
Correct |
8 ms |
792 KB |
Correct |
21 |
Correct |
9 ms |
792 KB |
Correct |
22 |
Correct |
9 ms |
1024 KB |
Correct |
23 |
Correct |
8 ms |
784 KB |
Correct |
24 |
Correct |
9 ms |
776 KB |
Correct |
25 |
Correct |
8 ms |
792 KB |
Correct |
26 |
Correct |
9 ms |
784 KB |
Correct |
27 |
Correct |
9 ms |
784 KB |
Correct |
28 |
Correct |
9 ms |
1020 KB |
Correct |
29 |
Correct |
8 ms |
772 KB |
Correct |
30 |
Correct |
9 ms |
772 KB |
Correct |
31 |
Correct |
8 ms |
776 KB |
Correct |
32 |
Correct |
8 ms |
792 KB |
Correct |
33 |
Correct |
8 ms |
772 KB |
Correct |
34 |
Correct |
9 ms |
1008 KB |
Correct |
35 |
Correct |
8 ms |
788 KB |
Correct |
36 |
Correct |
9 ms |
908 KB |
Correct |
37 |
Correct |
8 ms |
776 KB |
Correct |
38 |
Correct |
10 ms |
784 KB |
Correct |
39 |
Correct |
8 ms |
788 KB |
Correct |
40 |
Correct |
8 ms |
772 KB |
Correct |
41 |
Correct |
9 ms |
780 KB |
Correct |
42 |
Correct |
9 ms |
788 KB |
Correct |
43 |
Correct |
9 ms |
780 KB |
Correct |
44 |
Correct |
10 ms |
908 KB |
Correct |
45 |
Correct |
8 ms |
784 KB |
Correct |
46 |
Correct |
9 ms |
780 KB |
Correct |
47 |
Correct |
9 ms |
1016 KB |
Correct |
48 |
Correct |
9 ms |
888 KB |
Correct |
49 |
Correct |
8 ms |
772 KB |
Correct |
50 |
Correct |
11 ms |
780 KB |
Correct |
51 |
Correct |
8 ms |
788 KB |
Correct |
52 |
Correct |
9 ms |
1020 KB |
Correct |
53 |
Correct |
9 ms |
780 KB |
Correct |
54 |
Correct |
8 ms |
788 KB |
Correct |
55 |
Correct |
8 ms |
780 KB |
Correct |
56 |
Correct |
8 ms |
788 KB |
Correct |
57 |
Correct |
9 ms |
788 KB |
Correct |
58 |
Correct |
9 ms |
784 KB |
Correct |
59 |
Correct |
8 ms |
780 KB |
Correct |
60 |
Correct |
9 ms |
772 KB |
Correct |
61 |
Correct |
10 ms |
880 KB |
Correct |
62 |
Correct |
9 ms |
892 KB |
Correct |
63 |
Correct |
9 ms |
776 KB |
Correct |
64 |
Correct |
10 ms |
780 KB |
Correct |
65 |
Correct |
9 ms |
784 KB |
Correct |
66 |
Correct |
10 ms |
908 KB |
Correct |
67 |
Correct |
8 ms |
892 KB |
Correct |
68 |
Correct |
9 ms |
784 KB |
Correct |
69 |
Correct |
8 ms |
1016 KB |
Correct |
70 |
Correct |
9 ms |
644 KB |
Correct |
71 |
Correct |
9 ms |
896 KB |
Correct |
72 |
Correct |
9 ms |
1016 KB |
Correct |
73 |
Partially correct |
8 ms |
780 KB |
Wrong |
74 |
Partially correct |
10 ms |
924 KB |
Wrong |
75 |
Partially correct |
10 ms |
1024 KB |
Wrong |
76 |
Correct |
8 ms |
644 KB |
Correct |
77 |
Correct |
10 ms |
784 KB |
Correct |
78 |
Correct |
9 ms |
772 KB |
Correct |
79 |
Partially correct |
10 ms |
644 KB |
Wrong |
80 |
Partially correct |
11 ms |
888 KB |
Wrong |
81 |
Partially correct |
9 ms |
788 KB |
Wrong |
82 |
Partially correct |
9 ms |
788 KB |
Wrong |
83 |
Partially correct |
9 ms |
772 KB |
Wrong |
84 |
Partially correct |
10 ms |
772 KB |
Wrong |
85 |
Partially correct |
9 ms |
888 KB |
Wrong |
86 |
Partially correct |
9 ms |
780 KB |
Wrong |
87 |
Partially correct |
10 ms |
780 KB |
Wrong |
88 |
Correct |
9 ms |
784 KB |
Correct |
89 |
Correct |
8 ms |
1012 KB |
Correct |
90 |
Correct |
9 ms |
784 KB |
Correct |
91 |
Partially correct |
9 ms |
780 KB |
Wrong |
92 |
Partially correct |
8 ms |
780 KB |
Wrong |
93 |
Partially correct |
9 ms |
880 KB |
Wrong |
94 |
Partially correct |
9 ms |
824 KB |
Wrong |
95 |
Partially correct |
9 ms |
792 KB |
Wrong |
96 |
Partially correct |
9 ms |
876 KB |
Wrong |
97 |
Partially correct |
9 ms |
792 KB |
Wrong |
98 |
Partially correct |
10 ms |
784 KB |
Wrong |
99 |
Partially correct |
10 ms |
644 KB |
Wrong |
100 |
Partially correct |
8 ms |
792 KB |
Wrong |
101 |
Partially correct |
9 ms |
892 KB |
Wrong |
102 |
Partially correct |
9 ms |
784 KB |
Wrong |
103 |
Correct |
10 ms |
644 KB |
Correct |
104 |
Correct |
10 ms |
772 KB |
Correct |
105 |
Correct |
9 ms |
772 KB |
Correct |
106 |
Partially correct |
10 ms |
884 KB |
Wrong |
107 |
Partially correct |
8 ms |
792 KB |
Wrong |
108 |
Partially correct |
10 ms |
772 KB |
Wrong |
109 |
Partially correct |
10 ms |
1028 KB |
Wrong |
110 |
Partially correct |
8 ms |
1012 KB |
Wrong |
111 |
Partially correct |
8 ms |
908 KB |
Wrong |
112 |
Partially correct |
8 ms |
780 KB |
Wrong |
113 |
Partially correct |
8 ms |
788 KB |
Wrong |
114 |
Partially correct |
9 ms |
884 KB |
Wrong |
115 |
Partially correct |
9 ms |
784 KB |
Wrong |
116 |
Partially correct |
10 ms |
772 KB |
Wrong |
117 |
Partially correct |
9 ms |
1008 KB |
Wrong |
118 |
Partially correct |
10 ms |
776 KB |
Wrong |
119 |
Partially correct |
10 ms |
884 KB |
Wrong |
120 |
Partially correct |
10 ms |
1016 KB |
Wrong |