# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247192 | shenxy | Wine Tasting (FXCUP4_wine) | C++17 | 12 ms | 1052 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |