#include "bartender.h"
#include <algorithm>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> os;
vector<int> BlendWines(int K, vector<int> R){
vector<int> ans(R.size(), 0);
__int128_t x = 0, fac[R.size()];
os a;
for (int i = 1; i <= R.size(); ++i) a.insert(i);
fac[0] = 1;
for (int i = 1; i < R.size(); ++i) fac[i] = i * fac[i - 1];
for (int i = 0; i < R.size(); ++i) {
x = x + a.order_of_key(R[i]) * fac[R.size() - i - 1];
a.erase(R[i]);
}
for (int i = 0; i < R.size(); ++i) {
ans[i] = x % 13 + 1;
x /= 13;
}
return ans;
}
#include "taster.h"
#include <algorithm>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> os;
vector<int> SortWines(int K, vector<int> A) {
vector<int> ans(A.size(), 0);
__int128_t x = 0, fac[A.size()];
for (int i = A.size() - 1; i >= 0; --i) x = x * 13 + A[i] - 1;
os a;
for (int i = 1; i <= A.size(); ++i) a.insert(i);
fac[0] = 1;
for (int i = 1; i < A.size(); ++i) fac[i] = i * fac[i - 1];
for (int i = 0; i < A.size(); ++i) {
ans[i] = *a.find_by_order(x / fac[A.size() - 1 - i]);
x %= fac[A.size() - 1 - i];
a.erase(ans[i]);
}
return ans;
}
Compilation message
bartender.cpp: In function 'std::vector<int> BlendWines(int, std::vector<int>)':
bartender.cpp:13:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i <= R.size(); ++i) a.insert(i);
~~^~~~~~~~~~~
bartender.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < R.size(); ++i) fac[i] = i * fac[i - 1];
~~^~~~~~~~~~
bartender.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < R.size(); ++i) {
~~^~~~~~~~~~
bartender.cpp:20:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < R.size(); ++i) {
~~^~~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i <= A.size(); ++i) a.insert(i);
~~^~~~~~~~~~~
taster.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < A.size(); ++i) fac[i] = i * fac[i - 1];
~~^~~~~~~~~~
taster.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < A.size(); ++i) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
672 KB |
Correct |
2 |
Correct |
9 ms |
800 KB |
Correct |
3 |
Correct |
9 ms |
796 KB |
Correct |
4 |
Correct |
8 ms |
1020 KB |
Correct |
5 |
Correct |
8 ms |
796 KB |
Correct |
6 |
Correct |
8 ms |
664 KB |
Correct |
7 |
Correct |
10 ms |
668 KB |
Correct |
8 |
Correct |
11 ms |
792 KB |
Correct |
9 |
Correct |
8 ms |
900 KB |
Correct |
10 |
Correct |
10 ms |
668 KB |
Correct |
11 |
Correct |
9 ms |
900 KB |
Correct |
12 |
Correct |
9 ms |
904 KB |
Correct |
13 |
Correct |
9 ms |
664 KB |
Correct |
14 |
Correct |
8 ms |
668 KB |
Correct |
15 |
Correct |
8 ms |
644 KB |
Correct |
16 |
Correct |
10 ms |
1032 KB |
Correct |
17 |
Correct |
9 ms |
896 KB |
Correct |
18 |
Correct |
8 ms |
772 KB |
Correct |
19 |
Correct |
9 ms |
664 KB |
Correct |
20 |
Correct |
9 ms |
668 KB |
Correct |
21 |
Correct |
8 ms |
644 KB |
Correct |
22 |
Correct |
8 ms |
668 KB |
Correct |
23 |
Correct |
8 ms |
668 KB |
Correct |
24 |
Correct |
10 ms |
664 KB |
Correct |
25 |
Correct |
8 ms |
644 KB |
Correct |
26 |
Correct |
9 ms |
808 KB |
Correct |
27 |
Correct |
9 ms |
672 KB |
Correct |
28 |
Correct |
9 ms |
904 KB |
Correct |
29 |
Correct |
9 ms |
932 KB |
Correct |
30 |
Correct |
10 ms |
780 KB |
Correct |
31 |
Correct |
9 ms |
940 KB |
Correct |
32 |
Correct |
9 ms |
772 KB |
Correct |
33 |
Correct |
9 ms |
644 KB |
Correct |
34 |
Correct |
10 ms |
908 KB |
Correct |
35 |
Correct |
9 ms |
644 KB |
Correct |
36 |
Correct |
9 ms |
644 KB |
Correct |
37 |
Correct |
9 ms |
664 KB |
Correct |
38 |
Correct |
8 ms |
1028 KB |
Correct |
39 |
Correct |
9 ms |
772 KB |
Correct |
40 |
Correct |
8 ms |
908 KB |
Correct |
41 |
Correct |
10 ms |
900 KB |
Correct |
42 |
Correct |
9 ms |
1028 KB |
Correct |
43 |
Correct |
9 ms |
904 KB |
Correct |
44 |
Correct |
8 ms |
792 KB |
Correct |
45 |
Correct |
10 ms |
900 KB |
Correct |
46 |
Correct |
9 ms |
636 KB |
Correct |
47 |
Correct |
9 ms |
772 KB |
Correct |
48 |
Correct |
12 ms |
672 KB |
Correct |
49 |
Correct |
9 ms |
908 KB |
Correct |
50 |
Correct |
8 ms |
796 KB |
Correct |
51 |
Correct |
10 ms |
908 KB |
Correct |
52 |
Correct |
9 ms |
792 KB |
Correct |
53 |
Correct |
9 ms |
908 KB |
Correct |
54 |
Correct |
8 ms |
800 KB |
Correct |
55 |
Correct |
10 ms |
1052 KB |
Correct |
56 |
Correct |
8 ms |
672 KB |
Correct |
57 |
Correct |
8 ms |
676 KB |
Correct |
58 |
Correct |
8 ms |
644 KB |
Correct |
59 |
Correct |
9 ms |
872 KB |
Correct |
60 |
Correct |
9 ms |
676 KB |
Correct |
61 |
Correct |
9 ms |
664 KB |
Correct |
62 |
Correct |
8 ms |
668 KB |
Correct |
63 |
Correct |
8 ms |
772 KB |
Correct |
64 |
Correct |
9 ms |
804 KB |
Correct |
65 |
Correct |
9 ms |
772 KB |
Correct |
66 |
Correct |
10 ms |
780 KB |
Correct |
67 |
Correct |
8 ms |
644 KB |
Correct |
68 |
Partially correct |
8 ms |
672 KB |
Wrong |
69 |
Partially correct |
8 ms |
664 KB |
Wrong |
70 |
Partially correct |
9 ms |
800 KB |
Wrong |
71 |
Partially correct |
9 ms |
680 KB |
Wrong |
72 |
Partially correct |
9 ms |
920 KB |
Wrong |
73 |
Partially correct |
9 ms |
644 KB |
Wrong |
74 |
Partially correct |
9 ms |
896 KB |
Wrong |
75 |
Partially correct |
8 ms |
644 KB |
Wrong |
76 |
Correct |
9 ms |
660 KB |
Correct |
77 |
Correct |
9 ms |
668 KB |
Correct |
78 |
Correct |
9 ms |
676 KB |
Correct |
79 |
Partially correct |
9 ms |
900 KB |
Wrong |
80 |
Partially correct |
8 ms |
664 KB |
Wrong |
81 |
Partially correct |
8 ms |
772 KB |
Wrong |
82 |
Partially correct |
8 ms |
668 KB |
Wrong |
83 |
Partially correct |
8 ms |
660 KB |
Wrong |
84 |
Partially correct |
9 ms |
904 KB |
Wrong |
85 |
Partially correct |
9 ms |
780 KB |
Wrong |
86 |
Partially correct |
8 ms |
644 KB |
Wrong |
87 |
Correct |
10 ms |
900 KB |
Correct |
88 |
Correct |
8 ms |
780 KB |
Correct |
89 |
Correct |
8 ms |
896 KB |
Correct |
90 |
Correct |
8 ms |
676 KB |
Correct |
91 |
Partially correct |
8 ms |
1024 KB |
Wrong |
92 |
Partially correct |
9 ms |
904 KB |
Wrong |
93 |
Partially correct |
8 ms |
676 KB |
Wrong |
94 |
Partially correct |
8 ms |
672 KB |
Wrong |
95 |
Partially correct |
8 ms |
772 KB |
Wrong |
96 |
Partially correct |
8 ms |
668 KB |
Wrong |
97 |
Partially correct |
8 ms |
672 KB |
Wrong |
98 |
Partially correct |
10 ms |
792 KB |
Wrong |
99 |
Partially correct |
8 ms |
672 KB |
Wrong |
100 |
Partially correct |
9 ms |
1032 KB |
Wrong |
101 |
Partially correct |
8 ms |
676 KB |
Wrong |
102 |
Correct |
9 ms |
904 KB |
Correct |
103 |
Correct |
8 ms |
668 KB |
Correct |
104 |
Correct |
9 ms |
796 KB |
Correct |
105 |
Correct |
9 ms |
676 KB |
Correct |
106 |
Partially correct |
8 ms |
664 KB |
Wrong |
107 |
Partially correct |
8 ms |
796 KB |
Wrong |
108 |
Partially correct |
8 ms |
644 KB |
Wrong |
109 |
Partially correct |
9 ms |
676 KB |
Wrong |
110 |
Partially correct |
8 ms |
644 KB |
Wrong |
111 |
Partially correct |
9 ms |
672 KB |
Wrong |
112 |
Partially correct |
8 ms |
804 KB |
Wrong |
113 |
Partially correct |
8 ms |
672 KB |
Wrong |
114 |
Partially correct |
9 ms |
1020 KB |
Wrong |
115 |
Partially correct |
8 ms |
800 KB |
Wrong |
116 |
Partially correct |
9 ms |
772 KB |
Wrong |
117 |
Correct |
8 ms |
780 KB |
Correct |
118 |
Partially correct |
9 ms |
1024 KB |
Wrong |
119 |
Partially correct |
9 ms |
672 KB |
Wrong |
120 |
Partially correct |
10 ms |
644 KB |
Wrong |